Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: CC1310
Tool/software: TI-RTOS
Hi,
Tool/software: TI-RTOS 2.13.00.06
I'm implementing Modbus RTU slave on CC1310 hardware. Modbus protocol supposes receiving requests 1 byte at a time, measuring sub-byte timings to detect frame end (and frame errors).
I faced low UART performance (both in BLOCKING and CALLBACK modes) when receiving 1 byte at a time. I have the following simple code to measure receive timings:
void initialize_uart()
{
UART_Params uartParams;
/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.readMode = UART_MODE_BLOCKING;
uartParams.writeMode = UART_MODE_CALLBACK;
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.readDataMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_FULL;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.baudRate = MODBUS_UART_BAUDRATE;
uartParams.readTimeout = UART_WAIT_FOREVER;
uartParams.writeCallback = UartWriteCallback;
uart = UART_open(Board_UART0, &uartParams);
if (uart == NULL)
{
System_abort("Error opening the UART");
}
}
void initialize_modbus()
{
calculate_timeouts();
construct_timers();
resetRxBuffer();
initialize_uart();
for (;;)
{
t1 = Clock_getTicks();
int size = UART_read(uart, rxBuffer, UART_RX_BUFFER_SIZE); // 1 byte
memcpy(modbusRxBuffer + rxBufferLength, rxBuffer, size);
rxBufferLength += size;
t2 = Clock_getTicks();
System_printf("recieving took [%lu]us\n", (t2 - t1) * Clock_tick);
}
}
Using the above code I get approx 3.3ms per byte (stable). At 9600 baudrate it takes roughly 1ms to transfer 1 byte, and 3.3ms per byte leaves much to be desired.
My test app contains one more task that blinks LED, so it is not CPU heavy.
I have lifted UART interrupt priorities, but no luck there. Currently I have:
/* UART hardware parameter structure, also used to assign UART pins */
const UARTCC26XX_HWAttrsV2 uartCC26XXHWAttrs[CC1310_LAUNCHXL_UARTCOUNT] = {
{
.baseAddr = UART0_BASE,
.powerMngrId = PowerCC26XX_PERIPH_UART0,
.intNum = INT_UART0_COMB,
.intPriority = (2 << 5),
.swiPriority = 10,
.txPin = Board_UART_TX,
.rxPin = Board_UART_RX,
.ctsPin = PIN_UNASSIGNED,
.rtsPin = PIN_UNASSIGNED,
.ringBufPtr = uartCC26XXRingBuffer[0],
.ringBufSize = sizeof(uartCC26XXRingBuffer[0])
}
};
Can anyone explain what I am doing wrong with UART setup? Is it possible to reduce processing time?



