View previous topic :: View next topic |
Author |
Message |
gjs_rsdi
Joined: 06 Feb 2006 Posts: 468 Location: Bali
|
Automatic checksum |
Posted: Mon Mar 04, 2019 2:05 am |
|
|
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
|
|
Posted: Mon Mar 04, 2019 2:48 am |
|
|
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
|
|
Posted: Mon Mar 04, 2019 3:45 pm |
|
|
Thank you Ttelmah, always helpful answers
Best wishes
Joe |
|
|
|