3.c.07. Command 252: Get UART Error

Effect: This command loads into the mega168’s SPDR (SPI data register) the UART error byte, which reflects any UART errors that have occured. Sending a second byte (either the NULL command or a junk data byte) over the SPI once the value is loaded will transfer it to the mega644’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. As errors occur, bits in the error byte are set and remain set until the error byte is read. Reading the UART error byte will clear it. Every time a bit in the error byte is set, the mega168’s status byte has its STATUS_UART_ERROR bit set and the attention line is set. The UART error bits are as follows:

  • bit 0: UART_SEND_BUFF_OVERRUN — the mega644 sent a byte to the mega168 while the send buffer was full
  • bit 1: UART_READ_BUFF_OVERRUN — the mega168 received a byte over the UART while its read buffer was full
  • bit 2: UART_FRAME_ERROR — an incorrect stop bit (zero) was detected in the next readable frame (from UCSR0A)
  • bit 3: UART_DATA_OVERRUN — data was lost due to a receiver buffer full condition (from UCSR0A)
  • bit 4: UART_PARITY_ERROR — the next frame in the receive buffer had a parity error when received (from UCSR0A)
  • bit 5: UART_READ_BUFF_UNDERRUN — the mega644 requested a byte from an empty read buffer; the result of such a read would just be a junk byte (Note: this error bit does not exist in firmware version 1.00)
  • bits 6 & 7 are not used

Values sent: none

command byte = 252