AVR350
5
1472D-AVR-01/08
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
validate the packet
Act on data received or monitor errors
send an ACK or a NACK to sender
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 senders uart transmit buffer
Send a NACK
9.5 sendc.c
initialize timer1 counter for a 3 second delay
clear error flags
while buffer is not full
send ’C’ character to sender, signaling CRC mode
enable timer counter
wait for buffer full or timeout
if timed out clear error flags
restart timer
9.6 uart.c
check uart for framing or overrun errors
read byte from uart
verify first byte in receive buffer is valid
if buffer is full set buffer full flag