2 Theory of Operation Xmodem is a half-duplex communication protocol. The Receiver, after receiving a packet, will either acknowledge (ACK) or not acknowledge (NACK) the packet. The original Xmodem protocol used a standard checksum method to verify the 128-byte data packet. The CRC extension to the original protocol uses a more robust 16-bit CRC to validate the data block and is used here.
AVR350 5 Receiver Considerations This protocol NACKs the following conditions: 1. Framing error on any byte 2. OverRun error on any byte 3. CRC error 4. Receiver timed out (didn't receive packet within one second) On any NACK, the sender will re-transmit the last packet. Items one and two should be considered serious hardware failures.
Page 4
7 Modifications to Receive Protocol Users may wish to count how many “C’s” were sent during synchronization and after “n” number of tries abort the receive attempt. For embedded applications it’s not mandatory to have a 128-byte packet. You could have 64, 32, or even a 16-byte packet.
Page 5
AVR350 9 Pseudo-Code 9.1 purge.c initialize timer1 counter for a 1 second delay read uart for 1 second 9.2 receive.c send a ’C’ character to sender until receive buffer is full validate received packet send an ACK or a NACK to sender if packet was bad then wait for new good packet while not end of transmission wait for buffer to fill...
Page 6
9.7 validate_packet.c if not timed out then if no uart framing or overrun errors then if first character in buffer is SOH then if second character in buffer is the next packet number then if second character in buffer plus the third character in buffer = 0xff then compute CRC on packet data...
Page 7
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein.
Need help?
Do you have a question about the AVR AVR350 and is the answer not in the manual?
Questions and answers