CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Set the 232C data bits to 7 bits

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
janet24



Joined: 16 Apr 2019
Posts: 1

View user's profile Send private message

Set the 232C data bits to 7 bits
PostPosted: Tue Apr 16, 2019 1:22 am     Reply with quote

I want to receive data from the other party in 232C communication.
However, the other party transmits data bits in 7 bits.
If you set 7 bit as below, you can not receive.
If the other party is 8 bit, it will be received normally.
Someone please help me.

Code:

#include <18f46K22.h>
#fuses HSH,NOLVP,NOWDT,NOBROWNOUT,NOPLLEN,NOPBADEN,NOMCLR
#use delay(clock=20000000)
#use rs232(baud=2400, xmit=PIN_D6, rcv=PIN_D7,parity=e,bits=7)
temtronic



Joined: 01 Jul 2010
Posts: 9097
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Apr 16, 2019 5:15 am     Reply with quote

Quick reply...

I'd use ( 8-N-1) for the RS232 options
#use rs232(baud=2400, xmit=PIN_D6, rcv=PIN_D7, bits=8, parity=N, stop=1)

and simply mask (remove) the MSB as that bit would be the parity bit from the other device.

This should work providing the HW UART is being used.
You don't say if you have to confirm that parity is correct, that'd be more code and I don't know if USE RS232() will do that calculation for you.

I didn't see any info in the datasheet that the HW UART can be configured for parity so I suspect that USE RS232 is designed to do this.
Others will know....just have to wait a bit....

ALSO you MUST add 'ERRORS' to the options otherwise the UART will 'lockup' due to overflow of incoming data.

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group