Part Number: MSP432P401M
Tool/software: Code Composer Studio
Hello Team,
I have a problem what i don't understand. If read the uart and write back to CodeComposerStudio console and the uart to echo, then the UART call densely the Error callback function.
With 'fflush(stdout)' enough 4 character for the error. The console example with "12345\r\n" three times:
11
Uart Error: 32344
2311
Uart Error: 32344
211
Uart Error: 32344
2
If not fflush out evry character, it is much better. But if delay between lines less 70ms then also call Error.
For me coming densely 32344 error code. But sometimes come some other: 33196, 33180, 33168, 33188
What error code 32344 means?
I tried: with UART_MODE_CALLBACK, UART_readPolling, UART_MODE_BLOCKING, UART_read with timeout, UART_read with UART_WAIT_FOREVER
(Without the printf() the echo function working fine)
My simple Ti-RTOS code:
#include <stdint.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/runtime/Error.h>
#include <ti/sysbios/BIOS.h>
#include <ti/drivers/UART.h>
#include "ti_drivers_config.h"
UART_Handle uartConfig;
Semaphore_Handle SEMCONF_uart_rx;
void uartErrorCallback(uint32_t index)
{
printf("\r\nUart Error: %d \r\n", index);
}
void UART_RX_IRQHandler(UART_Handle handle, void *buffer, size_t num)
{
Semaphore_post(SEMCONF_uart_rx);
}
void initUart()
{
UART_Params uartParams;
Semaphore_Params sem_params;
Error_Block eb;
UART_init();
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = 115200;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readMode = UART_MODE_CALLBACK;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.readCallback = &UART_RX_IRQHandler;
uartConfig = UART_open(CONFIG_UART_0, &uartParams);
Semaphore_Params_init(&sem_params);
sem_params.mode = Semaphore_Mode_BINARY;
SEMCONF_uart_rx = Semaphore_create(0, &sem_params, &eb);
}
void *uartEchohThread(void *arg0)
{
char rxChar;
while (1) {
UART_read(uartConfig, &rxChar, 1);
Semaphore_pend(SEMCONF_uart_rx, BIOS_WAIT_FOREVER);
UART_writePolling(uartConfig, &rxChar, 1);
printf("%c", rxChar);
fflush(stdout);
}
}
Thanks for any help.
Regards,
Zsolt