treyz
Member level 5
Hi everyone
I am sending a stream of data from hypeterminal from a PC to a PIC 18F4680 via RS232.
Here the frame:
<STX><ADDR><DATAPAYLOAD=DATA+CHECKSUM><ETX<
Size.
STX = 0x02 (8-bit)
ADDR(8 or 9 bit, if ADDRESS is between 1 and 99,set the 9th bit at 1. If ADDRESS is at 0, clear the 9th bit)
DATA in 8-bit
CHECKSUM in 8-bit
ETX = 0x03(8-bit)
This is what the PIC should do:
- Receive the packet
- Check if the reception starts by 0x02,( if yes, check if ADDR is between 1 and 99 or at 0)
- Perform the checksum on <DATA>( Checksum = 2's complement)
- Wait for 0x03(ETX)
I wrote a piece of code,but I think I am confusing myself. Please Can I have some help?
I am sending a stream of data from hypeterminal from a PC to a PIC 18F4680 via RS232.
Here the frame:
<STX><ADDR><DATAPAYLOAD=DATA+CHECKSUM><ETX<
Size.
STX = 0x02 (8-bit)
ADDR(8 or 9 bit, if ADDRESS is between 1 and 99,set the 9th bit at 1. If ADDRESS is at 0, clear the 9th bit)
DATA in 8-bit
CHECKSUM in 8-bit
ETX = 0x03(8-bit)
This is what the PIC should do:
- Receive the packet
- Check if the reception starts by 0x02,( if yes, check if ADDR is between 1 and 99 or at 0)
- Perform the checksum on <DATA>( Checksum = 2's complement)
- Wait for 0x03(ETX)
I wrote a piece of code,but I think I am confusing myself. Please Can I have some help?
Attachments
Last edited: