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

Part Number: TMDSEVM572X


Tool/software: TI-RTOS

Hi,

sdk: processor_sdk_rtos_am57xx_3_02_00_05

pdk: pdk_am57xx_1_0_5

I want to read bytes on UART 3. I want to set this UART port in Hw interrupt mode.

I did the following changes in the code.

#define UART_INSTANCE 2

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

boardCfg = BOARD_INIT_PINMUX_CONFIG |
BOARD_INIT_MODULE_CLOCK | BOARD_INIT_UART_STDIO;
Board_init(boardCfg);

/***************************************UART_In_Callback();***************/
/* Get the default UART init configurations */
UART_socGetInitCfg(UART_INSTANCE, &uart_cfg);
uart_cfg.edmaHandle = NULL;
uart_cfg.dmaMode = FALSE;
uart_cfg.loopback = FALSE;
/* Set the DMA enabled UART init configurations */
UART_socSetInitCfg(UART_INSTANCE, &uart_cfg);
/* Set callback mode for both read and write */
UART_Params_init(&uartParams);
uartParams.readCallback = UART_callback;
uartParams.readMode = UART_MODE_CALLBACK;
uart = UART_open(UART_INSTANCE, &uartParams);

void UART_callback(UART_Handle handle, void *buf, size_t count)
{
int32_t Count_encoder,addrScanPrompt;
addrScanPrompt= (int32_t)scanPrompt;
Count_encoder=UART_read(uart, (void *)addrScanPrompt, UART_TEST_READ_LEN);
Cnt=Cnt+Count_encoder;
}

and send the Cnt value on serial. But the UART_callback function is not getting call.

I think i am doing something wrong or not able to configure uart properly.

I want to read data in interrupt mode. Please help me to solve the issue

Thanks,

Anjana Pathak

  • The RTOS team have been notified. They will respond here.
  • The call back configuration seems to be correct. After modifying the header, did you rebuild the board library. in order to enable a specific UART instance, you need to ensure pinmux, clocks, and driver code is modified accordingly. Also make sure the UART instance has correct level shifters so that they can communicate with the serial interface on the HOST PC.

    For AM572x, here are some steps that we had used to enable UART9 on the expansion connector of the AM572x GP EVM.
    e2e.ti.com/.../2085526

    Also, look at the steps for modifying UART instance using Processor SDK RTOS:

    http://www.ti.com/lit/an/sprac32/sprac32.pdf


    Regards,
    Rahul

  • Hi Rahul,

    Thanks a lot for this information.

    I want to know why BOARD_UART_INSTANCE is set to 2 is this the requirement to enable UART 3?

    How do enable other UARTs like 9,10,1,8. if i want to use 2 UARTs at a time in interrupt mode? is that i only need to modify evmAM572x_clocks.c as mentioned in attached e2e forum.

    I have not modified header file to enable UART as want to use Rx of  UART3 which is set as default port for debug console FTDI. Here only i want to read data through Rx of UART 3 in innterrupt mode so i configure it in callback mode. but i think callback function is not working.

    Thanks,

    Anjana Pathak

  • The TRM numbers the UART instances from UART1 to UART10 ...but in software they are numbered from UART0-UART9. Hence the need to set instance to 2 to enable UART3.

    Different UART instances may require different number of changes because the board library provided is designed to use only the interfaces available on the TI evaluation platforms. Hence I forwarded you the app note as it list all the changes required to enable a UART instance.

    In our usecase, we picked UART9 for our experiments because the pins could be accessed on the board and enabling it required minimal changes. We enabled UART9 on GP EVM as we wanted the slave core to use a different UART because UART3 was being used by slave code but for any other UART instance, you will need to ensure that the pinmux, clocks and the interrupts (optional) are configured as desired and the board library picks up the changes. Interrupt configurationis optional as the default uart_soc.c file for all platforms has this configuration using a default mapping.

    Regards,
    Rahul
  • Hi Rahul,

    So if i change UART instance to 8 for UART9 and update changes in evmAM572x_clocks.c as mentioned in attachment, UART 9 will be enabled and UART3 is also enabled?

    Sorry i am asking these question as not yet i am able to understand how i will be using these UART in interrupt mode. 

     

    Thanks a lot,

    Anjana Pathak

     

  • Anjana,

    Currently the board library only enables one UART instance in the code. If you want to enable 2 UARTS that you will need to add another instance by doing the following

    #define BOARD_UART_INSTANCE 2
    
    #define BOARD_UART_INSTANCE_1 8

    Make the required modifications in the _clock.c file and under evmAM572x_lld_init.c, add the code to initialize the second UART instance in Board_uartStdioInit

    UART_stdioInit(BOARD_UART_INSTANCE);
    
    UART_stdioInit(BOARD_UART_INSTANCE_1);

    This initializes the UART using Default UART init Parameters which I think is in BLOCKING mode so change the default to interrupt mode.  Locate the default settings in file UART_drv.c

    /* Default UART parameters structure */
    const UART_Params UART_defaultParams = {
        UART_MODE_BLOCKING,           /* readMode */
        UART_MODE_BLOCKING,           /* writeMode */
        SemaphoreP_WAIT_FOREVER,      /* readTimeout */
        SemaphoreP_WAIT_FOREVER,      /* writeTimeout */
        NULL,                        /* readCallback */
        NULL,                 /* writeCallback */
        UART_RETURN_NEWLINE,  /* readReturnMode */
        UART_DATA_TEXT,       /* readDataMode */
        UART_DATA_TEXT,       /* writeDataMode */
        UART_ECHO_OFF,         /* readEcho */
        115200,               /* baudRate */
        UART_LEN_8,           /* dataLength */
        UART_STOP_ONE,        /* stopBits */
        UART_PAR_NONE,        /* parityType */
        NULL,                 /* readCallback2 */
        NULL,                 /* writeCallback2 */
    };

    Change the setting from UART_MODE_BLOCKING to UART_MODE_CALLBACK.


    You need to rebuild the UART driver, BOARD library and then your application (in that order) for this to take effect.


    Hope this helps.

    Regards,

    Rahul

  • Thanks a lot for the great response.....
    Will do the changes and test it.

    Thanks once again,
    Anjana Pathak