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

Automatic checksum

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



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

Automatic checksum
PostPosted: Mon Mar 04, 2019 2:05 am     Reply with quote

I am reading the data sheet of PIC18F27K42 and found in two places written that it has Automatic checksum for the UART module.

I didn't find explanation about it in the data sheet, how it works, etc.
I am missing something?

Best wishes
Joe
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Mon Mar 04, 2019 2:48 am     Reply with quote

Clear the U0TXCHK register. Then set the C0EN bit in the UART.
Then send data, and the U0TXCHK register will contain the sum generated.
You read the byte in U0TXCHK, invert it, and send this as the last byte
after your data.
On receive, do the same, except clear the U0RXCHK register.
After the data is received, read U0RXCHK, add one to this. If the result
is zero, the checksum is OK.
If you are using 7bit mode you have to set bit 7 of the value before adding.
gjs_rsdi



Joined: 06 Feb 2006
Posts: 468
Location: Bali

View user's profile Send private message Send e-mail

PostPosted: Mon Mar 04, 2019 3:45 pm     Reply with quote

Thank you Ttelmah, always helpful answers Smile

Best wishes
Joe
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