C.07. command 252: get uart error, D. miscellaneous commands, D.01. command 218: get status – Pololu Orangutan X2 User Manual

Page 19: Section 3.c.07

Advertising
background image

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

3.d. Miscellaneous Commands
3.d.01. Command 218: Get Status

Effect: This command loads into the mega168 SPDR (SPI data register) the mega168’s status byte. 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. The status byte contains important information that the mega644 should know about the mega168’s status.
The mega168 sets the attention line whenever it sets any bits in the status byte. Sending this command will clear
the attention line and the latched bits of the mega168’s status byte. The bits of the status byte are enumerated as
follows:

bit 0: STATUS_UART_ERROR

— a UART error has occured, read the UART error byte for further

details. This bit is latched and will remain set until the status byte is read.

bit 1: STATUS_UART_READ_READY

— the read buffer is ready to be read according to the read-

ready bytes setting. This bit reflects the real-time state of the read buffer and is not cleared by reading the
status byte.

bit 2: STATUS_UART_SEND_FULL

— the send buffer contains 32 bytes and does not have room for

any more. This bit reflects the real-time state of the send buffer and is not cleared by reading the status byte.

Orangutan X2 Command Documentation v1.01

© 2001–2010 Pololu Corporation

3. Low-Level SPI Commands

Page 19 of 27

Advertising