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/TDA2P-ACD: Unable To Receive Databytes over UART2

Part Number: TDA2P-ACD

Tool/software: TI-RTOS

Hello,

I am working with TDA2P based customized board in which TDA2P is interfaced to a safety micro TI TMS570. I am using Processor SDK 03.03.

I am trying to establish a communication between TDA2P and TMS over UART. TDA2P's UART2 (instance 1) is interfaced to the UART of TMS.

For TDA2P, I referred to "uart_echo" example code from "PROCESSOR_SDK_VISION_03_03_00_00/ti_components/drivers/pdk_01_09_00_17/packages/ti/drv/bsp_lld/uart/examples". Using this example code, I have created an application which has a read task to read data over UART2 from TMS.

Currently, the data bytes sent by TDA2P are received by TMS but TDA2P does not receive anything from TMS. I debugged the code to find out that in the read task, my code never comes out of the GIO_read API call.

Below code is UART init and my read task,

"

    /* Adding UART2 device */
    status = GIO_addDevice("/uart1", (xdc_Ptr) &Uart_IOMFXNS, &init_UART,
    UART2_INSTANCE, (xdc_Ptr) &uartParams);

void init_UART(void)
{
    uartParams = Uart_PARAMS;
    uartParams.opMode = UART_OPMODE_POLLED;
    uartParams.hwiNumber = 8U;
    uartParams.rxThreshold = UART_RXTRIGLVL_8;
    uartParams.txThreshold = UART_TXTRIGLVL_56;
    uartParams.baudRate = UART_BAUDRATE_115_2K;
    uartParams.charLen = UART_CHARLEN_8;
    uartParams.stopBits = UART_NUMSTOPBITS_1;
    uartParams.parity = UART_PARITY_NO;
    uartParams.prcmDevId = 1; /* 1 is instance number of UART2 */
}

void uart2_ReadTsk(void)
{
    Bool exitLoop = FALSE;
    size_t len = 0, totalLen = 0;
    char *pRxBuf = NULL;
    Int status = IOM_COMPLETED;

    /* Now the user will input a string of APP_UART_NUM_BYTES bytes.
     * Hence submit a read request for APP_UART_NUM_BYTES bytes and loop
     * till we receive that many bytes */
    while (exitLoop != TRUE)
    {
        len = APP_UART_NUM_BYTES - totalLen;
        status = GIO_read(uartRxHndl, &uart2RxBuf[totalLen], &len);
        if (IOM_COMPLETED != status)
        {
            /* Report Error */
            Vps_printf("\r\nUART : GIO_read failed. returned : %d \r\n",
                       status);
        }

        totalLen += len;
         if (totalLen >= APP_UART_NUM_BYTES)
         {
         exitLoop = TRUE;
         }
    }

    return;
}

"

I have highlighted the GIO_read call where my code hangs. I have not called "Uart_init()" as it already called from Utils functions during init.

Can anyone suggest what can be the issue here as I am able to transmit data but I am not able to receive any data over UART2.

Regards,

Abhay

  • Hi Abhay,

    The GIO_read is a blocking call and the function will not return unless the len number of bytes are received or LF/CR is received.

    Can you check if the pinmux is done for hte Rx lines?

    Also note that the instance numbers in driver (parameter to GIO_addDevice) starts from 0.
    Make sure you have initialized the driver for proper instance which is connected on your EVM.

    Regards,
    Prasad
  • Hi Prasad,

    Thanks for your reply.
    I have done the pinmuxing for UART2 and checked the registers in memory browser. Also proper instance num (1 for UART2) is given to GIO_addDevice API.
    I think TMS is not sending len number of bytes to TDA2P that's why GIO_read API is blocked. I will check this and update you.

    Thanks,
    Abhay
  • Hi Abhay,

    As a quick experiment you can send one byte data from TMS and receive it on TDA2P.
    This will confirm if the connection is fine.

    Regards,
    Rishabh
  • Hi Prasad,

    I tried by sending len number of bytes from TMS side, still GIO_read() is blocked. Can you verify my below UART settings and let me know if anything is missing.

    "

    Uint32 configureUART(void)
    {
        Uint32 status = uSTATUS_OK;
        Uart_ChanParams chanParams;
        Error_Block eb;
        GIO_Params ioParams;

        status = GIO_addDevice("/uart1", (xdc_Ptr) &Uart_IOMFXNS, &init_UART, 1U, (xdc_Ptr) &uartParams);

        Error_init(&eb);

        /* Initialize channel attributes */
        GIO_Params_init(&ioParams);

        /* Cross bar event disabled */
        chanParams.crossBarEvtParam.isCrossBarIntEn = (UInt32) TRUE/*FALSE*/;
        chanParams.crossBarEvtParam.intNumToBeMapped = CSL_XBAR_INST_IPU1_IRQ_31/*0xFF*/;

        ioParams.chanParams = (Ptr) &chanParams;
        ioParams.model = GIO_Model_STANDARD;

        /* create the required channels(TX/RX) for the UART2 */
        uartTxHndl = GIO_create("/uart1", GIO_OUTPUT, &ioParams, &eb);
        uartRxHndl = GIO_create("/uart1", GIO_INPUT, &ioParams, &eb);

        if ((NULL == uartRxHndl) || (NULL == uartTxHndl))
        {
            status = uSTATUS_FAIL;
        }

        return status;
    }

    void init_UART(void)
    {
        UInt32 uartDevId = 1U;
        DEV_Params  devParams;

        uartParams = Uart_PARAMS;
        uartParams.opMode = UART_OPMODE_POLLED;
        uartParams.hwiNumber = CSL_XBAR_INST_IPU1_IRQ_31; //8U or 9U;
        uartParams.rxThreshold = UART_RXTRIGLVL_8;
        uartParams.txThreshold = UART_TXTRIGLVL_56;
        uartParams.baudRate = UART_BAUDRATE_115_2K;
        uartParams.charLen = UART_CHARLEN_8;
        uartParams.stopBits = UART_NUMSTOPBITS_1;
        uartParams.parity = UART_PARITY_NO;
        uartParams.prcmDevId = 1; /* 1 is instance number of UART2 */
        uartParams.enableCache = (Bool) FALSE;

        DEV_Params_init(&devParams);
        devParams.deviceParams = &uartParams;
        devParams.initFxn = NULL;
        devParams.devid = uartDevId;
    }

    "

    With the above settings I am able to transmit over UART2 though.

    Hi Rishabh,

    I tried by sending a single byte data from TMS to TDA2P. But GIO_read() call on TDA2P is not receiving anything.

    Regards,

    Abhay

  • Hi Abhay,

    Is pin mux fine? Can you probe and check if any data is being sent by TMS.

    Regards,
    Rishabh
  • Hi Rishabh,

    Yes I checked the register values in the memory browser of CCS for which I am doing the pinmux as below and I was able to read the values which were set.

    void PlatformUART2SetPinMux(void)
    {
    /* Pin_num, Muxmode, pullud_enable, pull_typeselect, io, slewrate, wakeupmode */
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_UART2_TXD, //UART2 TXD
    0x00000);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_UART2_RXD, //UART2 RXD
    0x40000);

    /* Enabling UART2 CLK */
    HW_WR_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_UART2_CLKCTRL, PRCM_ENABLE);
    while ((HW_RD_REG32(SOC_L4PER_CM_CORE_BASE + CM_L4PER_UART2_CLKCTRL)
    & ((UInt32) (0x00030000))) != 0x0)
    {
    /* Do nothing - Busy wait */
    }
    }

    I will check for probe points on our custom board to see whether TMS is sending the data or not.

    Thanks,
    Abhay
  • Hi Abhay,

    Can you also see what is the value of CM_L4PER_UART2_CLKCTRL register.

    Regards,
    Rishabh
  • Hi Rishabh,

    The value of CM_L4PER_UART2_CLKCTRL (0x4A009848) was read as 0x00000002.

    Regards,
    Abhay
  • Hi Abhay,

    PRCM seems fine. Can you probe and see if TMS is sending data as suggested earlier.

    Regards,
    Rishabh
  • Hi Rishabh,

    I probed and found that data is sent by TMS on UART. But TDA2P does not receive anything.

    Can you verify my UART settings from the above post. Am I missing anything.

    Regards,

    Abhay

  • Hi Rishabh,

    Do you think I have missed anything in UART settings ?

    Regards,
    Abhay
  • Hi Rishabh,

    Can you guide us where exactly to look for to solve this issue.

    Thanks,
    Abhay
  • Hi Abhay,

    The pad configuration for UART2_Rxd looks incorrect.
    For the pad CTRL_CORE_PAD_UART2_RXD, mux mode of 0 is reserved. You need to set mux mode to 4 for UART2_Rxd
    Can you update that and check?

    Regards,
    Prasad
  • Hi Prasad,

    Thanks for reply. I will test it with the pin mux change suggested by you and will update you.

    Regards,
    Abhay
  • Hi Prasad,

    With the below pin mux settings we are able to receive data over UART2,

    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_UART2_TXD, //UART2 TXD
    0x00004);
    HW_WR_REG32(SOC_CORE_PAD_IO_REGISTERS_BASE + CTRL_CORE_PAD_UART2_RXD, //UART2 RXD
    0x40004);


    I have one more doubt regarding the number of bytes to be received. While calling GIO_read(), is it necessary to specify the number of bytes to be received ?

    "
    len = 8;
    status = GIO_read(uartRxHndl, &uart2RxBuf, &len);
    "

    In the above code snippet, when I don't specify any value to "len", we don't receive anything.
    If I want to receive random number of data bytes from TMS to TDA2P over UART2, how can I do that.

    Regards,
    Abhay
  • Hi Abhay,

    Glad that the issue to receive data over UART2 is resolved.
    GIO_read is used to read a specified number of data from the communication channel.
    Hence you need to specify the number of bytes you want to read.

    Regards,
    Rishabh
  • Hi Rishabh,

    Ok. We will updated our code accordingly.
    Thank you for your support.

    Hi Prasad,

    Thank you for your support.

    Regards,
    Abhay
  • Hi Abhay,

    Kindly mark the post that answers your query as "This resolved my issue" and close the thread.

    Regards,
    Rishabh