Effect: If there is a byte in the UART read buffer, this command will remove it from the buffer and load it into the mega168’s SPDR (SPI data register). Sending a second byte over the SPI once the value is loaded (either the NULL command or some junk data byte) will transfer the UART byte to to the 644’s SPDR. It is recommended you do not begin transmission of this second byte until 3 us after the transmission of the command byte has completed. This is to make sure the mega168 has time to load the SPDR.
The UART read buffer is a 32-byte circular buffer that is automatically populated by the mega168 as data comes in over the UART. It is important you verify the read buffer actually has data before initiating a read as reading from an empty buffer will simply return junk. When the read buffer contains a certain amount of bytes, the mega168 status byte has its STATUS_UART_READ_READY bit set and the attention line is set. The number of bytes it takes to trigger this status change defaults to one and can be set by the Set Read Ready Size command (227—Section 3.c.06). The number of unread bytes in the read buffer can be obtained at any time by sending the Get Number of Bytes in Read Buffer command (223—Section 3.c.05).
If a read error occurs when the mega168 is attempting to read a packet over the UART, the mega168’s status byte has its STATUS_UART_ERROR bit set and the attention line is set. The UART error byte is set to reflect the nature of the read error: read buffer overrun, frame error, data overrun, or parity error. A read buffer overrun occurs if a byte comes in over the UART when the 32-byte read buffer is full. The other errors are generated automatically by the UART and obtained from the UART control and status register UCSR0A. The UART error byte can be read by sending the Get UART Error command (252—Section 3.c.07).
Values sent: none
command byte = 219
US toll free: 1-877-7-POLOLU ~