Specifications
15
AVR064
2529A–AVR–11/02
Transmit Packet to PC These routines transmit the data from ATmega169 to the PC.
Figure 13. Transmit Packet to PC
A transmit packet starts with the preamble bytes, and then the HEX-bytes that are to be
transmitted get converted to ASCII-bytes and loaded in the packet. Between each HEX-
byte that gets converted, an ASCII-byte for space (0x20) is inserted. At the end of the
packet, an ASCII-byte for Line Feed is added to indicate the end of frame. The transmis-
sion starts by enabling the UDRE interrupt. When all bytes are transmitted the UDRE
interrupt gets disabled.
Load Preamble Bytes
in Transmit Buffer
HEX Bytes
Left to Convert?
Enable UDRE
Onterrupt, that will
Start the Transfer.
Load 0x0D,
ASCII:"Line Feed" in
the End of Packet
YES
YES
NO
NO
interrupt [USART0_UDRE_vect] void USART0_UDRE_interrupt(void)
Bytes Left to
Send?
Disable
UDRE
Interrupt
Transmit
One Byte
Ongoing
Transmission?
YES
NO
Load 0x20, ASCII: "Space"
in Transmit Buffer.
Convert One
HEX Byte to
2-3 ASCII Bytes.
Send_TX_data
UDRE Interrupt
Return from
Interrupt
Return