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/TMDSEVM572X: UART use in interrupt mode

Hi,

I initialize UART 3 in Uart call back mode

char scanPrompt_try[256];

UART_Params uartParams;
/* UART SoC init configuration */
UART_HwAttrs uart_cfg;

UART_init();
/***************************************UART_In_Callback();***************/
/* Create call back semaphore */

/* Get the default UART init configurations */
UART_socGetInitCfg(UART_INSTANCE, &uart_cfg);
uart_cfg.edmaHandle = NULL;
uart_cfg.dmaMode = FALSE;
uart_cfg.loopback = FALSE;

UART_socSetInitCfg(UART_INSTANCE, &uart_cfg);

/* Set callback mode for read */
UART_Params_init(&uartParams);
uartParams.readCallback = UART_callback;
uartParams.readMode = UART_MODE_CALLBACK;
uart = UART_open(UART_INSTANCE, &uartParams);

While(1)

{

Count_encoder=UART_read(uart, &scanPrompt_try,1);
if(Count_encoder!=UART_ERROR)
{
ACnt=ACnt+1;
UART_putNum_Anjana(ACnt);

}
if(ACnt>=196)
{
ACnt=0;
UART_write(uart, &scanPrompt_try, 3);
}

}

UART_read returns -1 and 0 but it does not return no of bytes read. Please tell me why is this so?

and many times is gives run time error after reading some bytes. and the run time error is CortexA15_0: Unhandled ADP_Stopped exception 0x20023

Thanks,

Anjana Pathak

 

  • The RTOS team have been notified. They will respond here.
  • I did some changes in my code and the run time error is removed.

    As i am using UART 3 in interrupt/Callback mode. i am initializing the UART param in the intialization function as shown below. One call back function in main file. this call back function is working when the time difference between two byte is 100ms but if the difference reduces to 7.5ms it stops receiving bytes callback function is not called. 

    Please let me know is that i am missing some compilation procedure or net to do some other setting.

     

    UART_Params uartParams;
    /* UART SoC init configuration */
    UART_HwAttrs uart_cfg;
    SemaphoreP_Params semParams;
    UART_init();
    /***************************************UART_In_Callback();***************/
    /* Create call back semaphore */
    UART_osalSemParamsInit(&semParams);
    semParams.mode = SemaphoreP_Mode_BINARY;
    callbackSem = UART_osalCreateBlockingLock(0, &semParams);
    /* Get the default UART init configurations */
    UART_socGetInitCfg(UART_INSTANCE, &uart_cfg);
    uart_cfg.edmaHandle = NULL;
    uart_cfg.dmaMode = FALSE;
    uart_cfg.loopback = FALSE;

    UART_socSetInitCfg(UART_INSTANCE, &uart_cfg);

    /* Set callback mode for read */
    UART_Params_init(&uartParams);
    uartParams.baudRate = 76800;
    uartParams.parityType=UART_PAR_EVEN;
    uartParams.readCallback = UART_callback;
    uartParams.readMode = UART_MODE_CALLBACK;
    /*uartParams.writeCallback = NULL;
    uartParams.writeMode = UART_MODE_CALLBACK;*/
    uart = UART_open(UART_INSTANCE, &uartParams);
    if (uart == NULL)
    {
    goto Err;
    }


    addrScanPrompt= (int32_t)scanPrompt;
    if(UART_read(uart, (void *)addrScanPrompt,INPUT_LENGTH)==UART_ERROR)
    {
    goto Err;
    }
    while(1)
    {

    if(NextSerialData)
    {
    NextSerialData=0;
    HeadingMark=scanPrompt[0];
    UART_putNum_Anjana(AzimuthCnt);
    UART_write(uart, &scanPrompt,5);
    memset(scanPrompt, 0, sizeof(scanPrompt));
    UART_read(uart, (void *)addrScanPrompt,INPUT_LENGTH);
    if(ACnt>=96)
    {
    ACnt=0;
    }

    }

    }

    void UART_callback(UART_Handle handle, void *buf, size_t count)
    {
    ACnt=ACnt+count;
    NextSerialData=1;
    //memset(buf,0,INPUT_LENGTH);
    UART_osalPostLock(callbackSem);

    }

  • Please reply.......

    Is there any thing related to UART interrupt letancy.

  • Anjana,

    I am checking with the UART LLD developer, regarding what may be causing this issue with the driver. We had come across a similar issue on a different device and had fixed this by adjusting the UART FIFO trigger level on that device. I am checking if this patch was also submitted on AM57xx devices.

    Have you tried to use the EDMA based implementation to see if the issue still occurs. I will get back to you as soon as I hear back from the developer on this issue.

    Regards,
    Rahul
  • Ok thanks, waiting for the solution..

    No, i didn't tried to use EDMA based implementation.

    i think for that i need to set 

    uart_cfg.dmaMode    = True;

  • Hi Rahul,

    I am trying to change the parity of UART Parameter with the help of below setting in my main file

    UART_Params_init(&uartParams);
    uartParams.baudRate = 76800;
    uartParams.parityType= UART_PAR_EVEN;
    uartParams.readCallback = UART_callback;
    uartParams.readMode = UART_MODE_CALLBACK;
    /*uartParams.writeCallback = NULL;
    uartParams.writeMode = UART_MODE_CALLBACK;*/

    uart = UART_open(UART_INSTANCE, &uartParams);

    but the driver is at the same parity i.e. None. It is not changing the parityType to ODD or  EVEN.

    How do i change the parityType as per my requirement to establish the proper communication.

    Thanks,

    Anjana Pathak

     

  • Please reply it is urgent.............
  • The UART driver developer thinks the issue you originally reported may be caused due to RX FIFO trigger level size. The current default RX FIFO trigger level is set to 8 characters, if the UART read size is big in each read transaction, I would suggest to set a bigger trigger level (UART_RXTRIGLVL_16 or UART_RXTRIGLVL_56)

    Can you try updating the parameter in the file and rebuild the driver and give this a try.

    For the Parity issue, I was able to create a test case and do see the params being updated but the when I configure the Parity on my Host to even parity it does detect the serial transmission correctly and is shows gibberish data but when I set the Host to parity None, it shows the right data.
    I will need more time to debug this issue and get back to you.

    Regards,
    Rahul

  • I set the driver to use even parity and then configured the host serial connection to also use even parity but when the transmission occurs the host is not interpreting the data correctly but when I set the host back to none parity, the transmission is detected correctly indicating the driver is still transmitting using NONE parity setting. Please see the screenshot below:

    On further analysis, I looked at the UART_LCR register and the Parity is no enabled even if the driver calls

    If I manually enable the parity type 1 and parity enable the driver works correctly so I believe the issue is with the UARTLineCharacConfig CSL function.  

    I filed and issue and will work on providing a fix tomorrow.

    Regards,

    Rahul

  • Thanks a lot Rahul for your analysis.

    So where I need to do the changes in the code....

    Regrads,

    Anjana Pathak

  • 
    

    Anjana,

    I have a fix for your issue that should resolve your UART parity issue.

    Please make the following updates to the UART driver to fix this issue:

    diff --git a/UART.h b/UART.h
    index 09861f0..526f874 100644
    --- a/UART.h
    +++ b/UART.h
    @@ -294,10 +294,10 @@ typedef enum UART_STOP_e {
      */
    typedef enum UART_PAR_e {
         UART_PAR_NONE = 0,  /*!< No parity */
    -    UART_PAR_EVEN = 1,  /*!< Parity bit is even */
    -    UART_PAR_ODD  = 2,  /*!< Parity bit is odd */
    -    UART_PAR_ZERO = 3,  /*!< Parity bit is always zero */
    -    UART_PAR_ONE  = 4   /*!< Parity bit is always one */
    +    UART_PAR_ODD  = 1,  /*!< Parity bit is odd */
    +    UART_PAR_EVEN = 3,  /*!< Parity bit is even */
    +    UART_PAR_ONE  = 5,   /*!< Parity bit is always one */
    +    UART_PAR_ZERO = 7  /*!< Parity bit is always zero */
    } UART_PAR;
    
     /*!
    

    diff --git a/src/v1/UART_v1.c b/src/v1/UART_v1.c
    index 01e4fe9..772def5 100644
    --- a/src/v1/UART_v1.c
    +++ b/src/v1/UART_v1.c
    @@ -845,7 +845,7 @@ static UART_Handle UART_open_v1(UART_Handle handle, const UART_Params *params)
                 /* Configuring UART line characteristics */
                 UARTLineCharacConfig(hwAttrs->baseAddr,
                                      (object->params.dataLength | object->params.stopBits),
    -                                 object->params.parityType);
    +                                 (object->params.parityType << CSL_UART_LCR_PARITY_EN_SHIFT));
    

    I have attached the updates version of the 2 files that fix this issue.

    uart-lld-updates.zip

    Please let us know if this resolves your parity issue

    Regards,

    Rahul

  • For the trigger level change, you can look at the UART_test_fifo_trglvl and UART_test_trglvl function in the UART test Example provided under pdk_am57xx_1_0_7\packages\ti\drv\uart\test\src\main_uart_test.c

    We have both DMA version and non-DMA version of this test for your reference.

    Regards,
    Rahul
  • Thanks a lot Rahul..

    Now it is working with Even Parity...

    Regards,

    Anjana Pathak