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

How do you detect a parity error with a software USART?

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



Joined: 27 Oct 2004
Posts: 6
Location: Kuala Lumpur, Malaysia

View user's profile Send private message

How do you detect a parity error with a software USART?
PostPosted: Sat Oct 30, 2004 12:52 am     Reply with quote

Hi guys,

I would really appreciate your assistance for this beginner's problem:

I'm using the software USART of a PIC16F874 to receive information for display on an LCD panel. I noticed that there are occasional errors in my transmission, so I decided to enable Even parity.

Code:
#include <16f874.h>
#fuses XT,NOWDT,NOPROTECT,PUT,NOLVP
#use delay( clock=4000000 )
#use rs232( baud=1200, parity=E, bits=8, xmit=PIN_A4, rcv=PIN_A5, errors )


Unfortunately, RS232_ERRORS doesn't work with the software USART, giving an "Undefined identifier" compiler error (although the documentation says it's suppose to have some use). Therefore, I don't think I can test for any error conditions.

How would you guys do it?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Oct 30, 2004 8:15 am     Reply with quote

Quote:
Unfortunately, RS232_ERRORS doesn't work with the software USART, giving an "Undefined identifier" compiler error

From the documentation you can conclude the RS232_ERRORS variable in a No UART configuration only has a purpose when using 9 data bits and/or the FLOAT_HIGH option. You are using neither of these settings and therefor the variable is optimized away causing your error.

But then, you start wondering how the compiler can ever return a parity error... Being curious I looked into the code generated for the RS-232 software receive and it turns out the parity is not checked at all!!! The parity bit is just skipped and no checks are performed. I know the CCS documentation isn't perfect, but this omission surprises me a lot.
B.T.W. I checked in PCH v3.187
hentropy



Joined: 27 Oct 2004
Posts: 6
Location: Kuala Lumpur, Malaysia

View user's profile Send private message

PostPosted: Sun Oct 31, 2004 10:06 pm     Reply with quote

Thanks for your reply ckielstra. At least now i know there's _NO_ way to do that.
(I'm using PCM v 3.117.)
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Nov 01, 2004 4:26 pm     Reply with quote

Quote:
...At least now i know there's _NO_ way to do that.
Not quite. You can code your own software uart - then you can do whatever you want
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