background image

 

AVR350 

1472D-AVR-01/08 

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. Xmodem can be considered to be 
receiver driven. That is, the Receiver sends an initial character “C” to the sender 
indicating that it’s ready to receive data in CRC mode. The Sender then sends a 133-
byte packet, the Receiver validates it and responds with an ACK or a NACK at which 
time the sender will either send the next packet or re-send the last packet. This 
process is continued until an EOT is received at the Receiver side and is properly 
ACKed to the Sender. After the initial handshake the receiver controls the flow of data 
through ACKing and NACKing the Sender.  

Table 2-1. 

XmodemCRC Packet Format 

Byte 1 

Byte 2 

Byte 3 

Bytes 4 - 131 

 Bytes 132 - 133  

Start of Header 

Packet Number 

~(Packet Number) 

Packet Data  

16 bit CRC 

 

3 Definitions  

The following defines are used for protocol flow control. 

Table 3-1. 

Protocol Flow Control 

Symbol Description 

Value 

SOH  

Start of Header  

0x01 

EOT

 

End of Transmission 

0x04 

ACK Acknowledge 

0x06 

NACK Not 

Acknowledge 

0x15 

C ASCII 

“C” 

0x43 

 

Byte one of the XmodemCRC packet can only have a value of SOH or EOT, anything 
else is an error. Bytes two and three form a packet number with checksum, add the 
two bytes together and they should always equal 0xff. Please note that the packet 
number starts out at “1” and rolls over to “0” if there are more than 255 packets to be 
received. Bytes 4 - 131 form the data packet and can be anything. Bytes 132 and 133 
form the 16-bit CRC. The high byte of the CRC is located in byte 132.  

4 Synchronization  

The Receiver starts by sending an ASCII “C” (0x43) character to the sender indicating 
it wishes to use the CRC method of block validating. After sending the initial “C” the 
receiver waits for either a three second time out or until a buffer full flag is set. If the 
receiver is timed out then another “C” is sent to the sender and the three second time 
out starts again. This process continues until the receiver receives a complete 133-
byte packet. 

Summary of Contents for AVR AVR350

Page 1: ...s than 1K Bytes of Code Space C High level Language Code 1 Introduction The Xmodem protocol was created years ago as a simple means of having two computers talk to each other With its half duplex mode...

Page 2: ...132 133 Start of Header Packet Number Packet Number Packet Data 16 bit CRC 3 Definitions The following defines are used for protocol flow control Table 3 1 Protocol Flow Control Symbol Description Val...

Page 3: ...self correcting after the receiver NACKs the sender 6 Data Flow Diagram The data flow diagram below simulates a 5 packet file being sent Table 6 1 Data Flow Diagram Sender Receiver C Times Out after T...

Page 4: ...scillator This is sufficiently accurate at room temperature for operation up to 38 4K Baud For higher Baud rates the on board 3 6864MHz oscillator or a 7 3728 MHz crystal should be used with the init...

Page 5: ...9 3 recv_wait c initialize timer1 counter for a 1 second delay wait till buffer is full or timeout 9 4 respond c clear error flags If packet was good or end of transmission then Send an ACK Else Purge...

Page 6: ...cond character in buffer plus the third character in buffer 0xff then compute CRC on packet data if CRC ok then increment packet number packet good else packet bad else bad packet number checksum else...

Page 7: ...ARRANTY RELATING TO ITS PRODUCTS INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTY OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE OR NON INFRINGEMENT IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIR...

Reviews: