![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
janet24
Joined: 16 Apr 2019 Posts: 1
|
Set the 232C data bits to 7 bits |
Posted: Tue Apr 16, 2019 1:22 am |
|
|
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)
|
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9177 Location: Greensville,Ontario
|
|
Posted: Tue Apr 16, 2019 5:15 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|