Other Parts Discussed in Thread: CC3220MODA
Using the CC3220 with code based on the Network Terminal example we have tried to add a read from a UART to our system and need the read from that UART not to block.
We have experimented with turning on the UART time out and the following code to read the UART strings which are terminated with CR and or LF.
Our conditional test never sees the termination codes (CR LF). See line 32 of the code below.
Would like some ideas.
Lee Erickson
Here is the UART initialization:
//*****************************************************************************
//
//! Initialization
//!
//! This function
//! 1. Configures the UART to be used.
//!
//! \param none
//!
//! \return none
//
//*****************************************************************************
UART_Handle InitTerm(void)
{
UART_Params uartParams;
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_TEXT;
uartParams.readDataMode = UART_DATA_TEXT;
uartParams.readReturnMode = UART_RETURN_NEWLINE;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.readTimeout = 2000;
uartParams.baudRate = 115200;
uartHandle = UART_open(Board_UART0, &uartParams);
/* remove uart receive from LPDS dependency */
UART_control(uartHandle, UART_CMD_RXDISABLE, NULL);
uart1Handle = UART_open(Board_UART1, &uartParams); // GAA 30Aug2018
/* remove uart receive from LPDS dependency */
UART_control(uart1Handle, UART_CMD_RXDISABLE, NULL); // GAA 30Aug2018
return(uartHandle);
}
Here is the code:
//*****************************************************************************
// Non blocking
//! Rec chars from UART1 (RS485) and writes them to the global Rec buffer
//
//*****************************************************************************
void RS485Recvnb(void)
{
char cChar;
int i = 0;
int index1 =0;
int index2 =0;
int len=0;
memset((char *)gUARTRecBuf, 0, sizeof((char *)gUARTRecBuf));
gUARTRecBufIndex =0;
memset((char *)TempRecBuf, 0, sizeof((char *)gUARTRecBuf));
TempRecBufIndex =0;
cChar = 0;
while ( (cChar != '>') && (cChar !='#') ) {
UART_read(uart1Handle, &cChar, 1);
}
gUARTRecBuf[gUARTRecBufIndex++] = cChar;
UART_writePolling(uartHandle, &cChar, 1); // Echo the received character to the debug UART
while(1)
{
int_fast32_t testint = UART_read(uart1Handle, &cChar, 1);
UART_PRINT("%d/n", testint);
if ((cChar == '\r') || (cChar =='\n')) {
gUARTRecBuf[gUARTRecBufIndex++] = cChar;
UART_writePolling(uartHandle, &cChar, 1); // Echo the received character to the debug UART
break;
}
else {
gUARTRecBuf[gUARTRecBufIndex++] = cChar;
UART_writePolling(uartHandle, &cChar, 1); // Echo the received character to the debug UART
}
}
}


