Hi, Cypress Geeks and Gurus! I need your help!
There are more than a hundred ways to skin a cat and I can see that there might be many more incorrect ways to code RX-ing bytes with the Cypress PSOC 4200 SCB Standard UART.
I have another processor Tx-ing exactly 48 bytes to the PSOC RX pin at 115200 baud every few seconds.
I can't find any example on the web that shows how to receive multiple bytes by the Standard UART, I can find only a far too simple video that shows how to echo each byte received back to the sending terminal.
Only one UART, alias UA, RX only mode.
I have started the UART in main() correctly before the main() loop.
I have a char buffer Rx[48] to hold the receive bytes and the PSOC RX set to 115200,N,8,1 (same as TX source)
I have set the UART circular buffer RX FIFO buffer size to 48 bytes.
The only active interrupts I have selected is: RX FIFO buffer full, FIFO Overflow, Frame Error
I have come up with the code below:
Will this seemingly too simple code work and is it robust enough to deal with possible various RX receive errors?
//var initialization before main()
static char Rx[48];
static char j;
// in main()
if(UA_CHECK_CAUSE_INTR(UA_INTR_RX_FULL))
{
for(j=0;j<48;j++)
{ Rx[j]=UA_UartGetByte();
}
UA_rx_ClearInterrupt();
}
else if(UA_CHECK_CAUSE_INTR(UA_INTR_RX_ALL))
{
UA_rx_ClearInterrupt();
UA_Stop();
UA_Start();
}