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 CCS Technical Support

Handling UART errors

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



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

Handling UART errors
PostPosted: Thu May 02, 2019 7:56 am     Reply with quote

I'm trying to port a PIC18F code to PIC24FJ

In the old code I declared the bits FERR1 and OERR1 to handle the errors inside the interrupt.

Now I wonder if CCS compiler has some way to handle it in more portable way or should I declare those bits again.

CCS V5.078
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Thu May 02, 2019 8:15 am     Reply with quote

You do realise, that if you declare the UART setup, with the keyword
'ERRORS', the compiler automatically adds code to reset the errors, and
copies the error bits into the RS232_ERRORS register.
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Thu May 02, 2019 11:08 am     Reply with quote

Yes, but I haven't clear how it works.
Also, in the CCS help it says that copy the RCSTA register to RS232_BUFFER_ERRORS so you need to know how the hardware works and the bit order in order to check if there any error or if you can read new data.

I started about 20 years ago with pure assembler code and let that the compiler do the job makes me feel like I'm losing the control of the code and a bit messy.

Thinking a bit more may be I must use kbhit() before read from the hardware buffer and forgot about the errors bits.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Thu May 02, 2019 1:53 pm     Reply with quote

The OERR, and FERR bits are in the same location for all PIC's that I know.
The only difference for PIC24's, is you do have a PERR bit as opposed to
the software parity error bit that CCS generates on the PIC16/18.
Bit1 = OERR
Bit2 = FERR

Bit3 = PERR, while on the older PIC's without the hardware this is generated
into Bit0.

This is updated _when_ you have read a byte, and shows what errors were
found when the read routine was called.
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