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

Checking Parity in INT_RDA

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

Checking Parity in INT_RDA
PostPosted: Wed Aug 08, 2012 8:50 am     Reply with quote

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: 1706
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Aug 08, 2012 4:38 pm     Reply with quote

I don't see how you're testing for parity.

Can you please explain your code.

Mike
ljbeng



Joined: 10 Feb 2004
Posts: 205

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 9:16 am     Reply with quote

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: 1706
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Wed Aug 15, 2012 2:13 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library 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