PSoC® 1 UART cGetChar API Fails When the UART RxCmdBuffer Is Enabled – KBA89345 | Cypress Semiconductor
Support & Community
PSoC® 1 UART cGetChar API Fails When the UART RxCmdBuffer Is Enabled – KBA89345
The cGetChar API fails when the UART RxCmdBuffer is enabled in the UART user module parameters. What is the reason for this?
When the UART RxCmdBuffer is enabled, PSoC® Designer™ generates code that checks for the Rx Status register, reads the UART Rx data register, and stores the read values into the RAM variables (Rx buffer) in the UART Rx interrupt.
The UART's Rx Status register gets cleared in this process.
The cGetChar API polls for the Rx Status register and waits until the UART_RX_REG_FULL flag gets set. The UART Rx interrupt (that fills up the UART RxCmdBuffer) may clear the UART_RX_REG_FULL flag before cGetChar polls for the flag. In this case, cGetChar misses a byte and waits for the arrival of the next Rx byte, causing the API to fail.
When the UART RxCmdBuffer is enabled, the cGetChar API should not be used to get the received data. Instead, you need to use an RxCmdBuffer-related API (such as bCmdCheck(), szGetParam(), or szGetRestOfParams()) because the received data is already collected in the RAM variables and can be read using the RxCmdBuffer-related API. Refer to the 8-Bit UART Datasheet to see the APIs that are available when the RxCmdBuffer is enabled.