Q: How can the Apollo or Apollo2 be configured to generate an interrupt following UART reception of 1 or 2 bytes of data, since the smallest UART FIFO threshold setting is 4 bytes? Related, how can an interrupt be generated following x number of bytes where x is not a multiple of 4?
A: The UART RX FIFO threshold options are 1/8, 1/4, 1/2, 3/4, and 7/8 of the FIFO, and will trigger the RX FIFO interrupt once the FIFO fills to this level. The UART RX FIFO is 32 bytes total, so the smallest 1/8 threshold level is 4 bytes. The FIFO threshold setting is generally used to signal that the FIFO is getting full so that it can be emptied to support continuous reception. However it can be used to indicate a message has been received for use cases with fixed length messages that are a multiple of 4 bytes long.
The solution for generating an interrupt following reception of an arbitrary length of data is to enable the UART RX Timeout interrupt (AM_HAL_UART_INT_RX_TMOUT). The RX Timeout interrupt is the best indication that data reception has completed for an arbitrary length of received data. The RX Timeout interrupt will trigger once data reception of any length has stopped. The RX Timeout interrupt will trigger 32 bit-times after the last byte of data is received. The 32 bit-times are counted at the configured baud rate. For example, if the baud rate is 115.2 kbps, then the RX Timeout interrupt will trigger 278 us after the last byte of received data.
Comments
0 comments
Article is closed for comments.