View previous topic :: View next topic |
Author |
Message |
ljbeng
Joined: 10 Feb 2004 Posts: 205
|
Checking Parity in INT_RDA |
Posted: Wed Aug 08, 2012 8:50 am |
|
|
Search tags:
Check Parity
How to check parity
parity in interrupt
INT_RDA parity
I searched for help here but never found this exact routine. Trial and error got me to use long_int to receive 9 bits and check for parity using the 9th bit of ircv. If I used the hardware RCSTA.0, I got mixed results where parity was wrong 90% of the time.
Code: |
#use rs232(baud=300,parity=O,uart1,bits=8,errors,long_data)
int16 ircv,srerror,rcnt;
int1 parc;
int parp;
char rcvbuff[50];
#int_RDA
RDA_isr(){
#bit rx9d = ircv.8;
ircv = getc();
parc = 1;
for (parp=0;parp<=7;parp++){
if (bit_test(ircv,parp)) parc++;
}
if (rx9d != parc) {
srerror++;
return;
}
rcvbuff[rcnt] = ircv;
if (rcnt < 50) rcnt++;
else rcnt = 0;
}
|
|
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 08, 2012 4:38 pm |
|
|
I don't see how you're testing for parity.
Can you please explain your code.
Mike |
|
|
ljbeng
Joined: 10 Feb 2004 Posts: 205
|
|
Posted: Wed Aug 15, 2012 9:16 am |
|
|
If parity is good then rx9d will equal parc. If those don't match, I increment srerror and return. If they do match, I add the character to the rcvbuff array. |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 15, 2012 2:13 pm |
|
|
Quote: | I searched for help here but never found this exact routine. Trial and error got me to use long_int to receive 9 bits and check for parity using the 9th bit of ircv. If I used the hardware RCSTA.0, I got mixed results where parity was wrong 90% of the time. |
Sorry. It appears I have not understood your original post.
Were you saying:-
(1) The hardware RCSTA.0 gave the wrong result 90% of the time.
&
(2) Your code is perfect?
Mike |
|
|
|