Hi, i need help with UART.
UART_write() performs every 1 second by the timer. UART_read() in CallBack mode and it's triggering after each UART_write(), I don't understand why.
UART_read() must work independently from UART_write().
I tried using different arrays for reading and writing, it did't work.
Any help is appreciated.
void some_func()
{
}
void readCallback(UART_Handle Uhandle, void *rxBuf, size_t size)
{
Event_post(eventH, UART_RX_COMPLETE);
}
void clock_cb(UArg arg)
{
Event_post(eventH, TIMER);
}
void taskFxn(UArg arg0, UArg arg1)
{
eventH = Event_create(NULL, NULL);
UART_Params_init(&Uparams);
Uparams.writeDataMode = UART_DATA_TEXT;
Uparams.readDataMode = UART_DATA_TEXT;
Uparams.readMode = UART_MODE_CALLBACK;
Uparams.readEcho = UART_ECHO_OFF;
Uparams.readCallback = readCallback;
Uparams.baudRate = 9600;
Uhandle = UART_open(0, &Uparams);
UART_control(Uhandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE, NULL);
UART_read(Uhandle, buff, 10);
Clock_Params_init(&clockParams);
clockParams.arg = (UArg)eventH;
clockParams.startFlag = 0;
clockH = Clock_create((Clock_FuncPtr) &clock_cb, 100000, &clockParams, NULL);
Clock_start(clockH);
uint8_t counter = 0x0;
uint16_t events;
while(true)
{
events = Event_pend(eventH, Event_Id_NONE, 0xFFFFFFFF, BIOS_WAIT_FOREVER);
if (events & UART_RX_COMPLETE)
{
some_func();
Task_sleep (10000);
UART_read(Uhandle, buff, 10);
}
if (events & TIMER)
{
counter++;
buff[0] = counter;
UART_write(Uhandle, buff, 1);
Task_sleep (10000);
Clock_start (clockH);
}
}
}
Kind Regards, Egor