These flags are declared as external variables in sw_fifo.h. However, it is good practice to check if an overflow condition has occurred. If the buffer is made large enough, the user should be able get by without ever checking these flags. However, the user needs to manually clear the flags. These flags are automatically set by the software buffer when an overflow condition occurs. The software buffer contains two flags for monitoring software buffer overflow conditions. Volatile uint8_t uart_tx_fifo_not_empty_flag = 0 // this flag is automatically set and cleared by the software buffer Therefore, in order to use the flags, the user must declare them in their own main file (or wherever the flag check is being made) as shown below: volatile uint8_t uart_rx_fifo_not_empty_flag = 0 // this flag is automatically set and cleared by the software buffer The flags are declared as external variables in sw_fifo.h. Any user-function can check the flags at any time to see if data has exists in either buffer. The buffer uses external flags to indicate that data is present in the RX or TX software buffer. The user should keep the size of the buffer as small as possible while still ensuring no overflow occurs. The size of the buffer is defined by FIFO_BUFFER_SIZE in sw_fifo.h and is limited by the amount of RAM in the microcontroller. Data is entered and removed from the buffer in chronological order. The software buffer behaves like a circular First-In, First-Out (FIFO) buffer. Having prior knowledge of FIFO buffers is beneficial, but not required. ![]() It’s assumed that the reader has some prior experience with C/C++ programming language.To use this software buffer, the microcontroller must support “UART TX buffer empty” and “UART RX data received” interrupts.Alternatively, the microcontroller can be put in a lower power mode (if supported) while waiting for UART TX or RX. ![]() The buffer is interrupt driven which allows the microcontroller to execute functions in parallel with UART communication. The purpose of this library is to provide a generic software buffer for UART communication, written in easy-to-understand C/C++ programming language. ![]() Software data buffers alleviate this problem by providing a larger buffer to store data while waiting for the UART to shift data out-of the transmitter or into the receiver. This byte-by-byte “wait time” is amplified when a CPU is operating at higher speeds while using lower baud rates for UART communication. If a multi-byte transmit is needed, the user needs to wait for the UART transmitter to shift out all of its data byte by byte so that data is not overwritten or discarded. Typically, a microcontroller has only a one or two-byte hardware buffer for each UART receiver and transmitter. UART communication is a very simple and inexpensive means of serial communication in embedded designs. Created by Scott Schmit, last modified on Background
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |