This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/PROCESSOR-SDK-AM335X: Use UART as binary mode

Part Number: PROCESSOR-SDK-AM335X

Tool/software: TI-RTOS

Hello,

I'm trying to develop an application to a Sitara AM335x ,with BIOS 6.52.0.12, and PDK 1.0.10 with the developer board ICEv2 i'm trying to use the interface UART3 (default STDIO) as a uart in binary mode.

I load the default icev2 pinmux.

In .cfg file :

var Uart              = xdc.loadPackage('ti.drv.uart');

main.c:

boardCfg =
/* Enabling Board Pinmux */
BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK;

/* Initialize Board */
status = Board_init(boardCfg);
if (status != BOARD_SOK)
{
return (false);
}

UART_init();

UART_Params uartParams;
UART_Params_init(&uartParams);
uartParams.readMode = UART_MODE_BLOCKING;
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.readTimeout = 1000000;
uartParams.writeTimeout = 1000000;
uartParams.baudRate = 115200;
uartParams.readMode = UART_DATA_BINARY;
uartParams.writeMode = UART_DATA_BINARY;
uartParams.readReturnMode = UART_RETURN_NEWLINE;
uartParams.readEcho = UART_ECHO_OFF;
uartParams.dataLength = UART_LEN_8;
uartParams.stopBits = UART_STOP_ONE;
uartParams.parityType = UART_PAR_NONE;

tUartHnd = UART_open(3, &uartParams);
if(tUartHnd == NULL)
{
while (1);
}

So i disable the STDIO module and open the instance 3 as binary mode.

when i try to write to UART with:

UART_write(tUartHnd, (const char*)(pu8Buf), u16Size);

The characters '0xA' are changed to the characters '0xA 0xD'. I think that the interface UART3 is still in Text mode so all the New Line characters (0xA) are concatened by Carriage return characters (0xD).

  • The RTOS team have been notified. They will respond here.
  • Hello, after a several hours working in the issue i can find an alternative solution. First of all i change the default parameters of the UART to start working in Binary mode (the UART_defaultParams struct of UART_drv.c)

    Doing that solves the issue of adding the 0xD character after the 0xA char. But another issue appears, the character 255 or 0xFF is not read with the function UART_readPolling(). So reviewing the UART_v1.c file, it uses

    rdData = UARTCharGetNonBlocking(hwAttrs->baseAddr);
    if (rdData == (-((int8_t)1)))

    so it compares the character read with -1 (same as 255).

    I change that for:
    if (UARTCharsAvail(hwAttrs->baseAddr) == 0)
    {
    .
    .
    .
    }
    else
    {
    rdData = UARTCharGetNonBlocking(hwAttrs->baseAddr);

    Rebuild the uart, and it all seems to be working.
    Thanks.