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.

TI-RTOS/AM3358: Adding UART driver to project

Other Parts Discussed in Thread: PROFIBUS

Hello,

we are struggeling to add a UART driver to our project. here are some basic information:

- the project is based on the PRU-ICSS-Profinet_Slave_01.00.03.04 sample application on the AM335x ICE Board V2.

- we want to use the UART which is connected to the DB9 connector (the same which is used for PROFIBUS slave in other projects)

- we don't want to change the standard IO Uart from 0 to 1, because we don't need printf on the RS485, we want to implement a different protocol.

- I have searched for the UART samples, but they all are showing how to use the standard I/O driver.

is there any documentation or sample code how to add an UART to the application ? it seems that the UARTs are already added in the config file, but it seems that the project
was not based on Starterware (there is no Board_Init function in main), so the standard sample code is not working.

the UART should use the DMA because the frames can be longer. but a first hint how to start would be great.

Thank's in advance,

Dirk

  • Hi Dirk,

    Did you look into the UART example in PDK?

    http://software-dl.ti.com/processor-sdk-rtos/esd/docs/latest/rtos/index_device_drv.html#application 

    This UART_BasicExample_Dma_evmAM335x_armTestProject created by 'pdkProjectCreate.bat Am335x all little uart all arm' should help.

    Regards,
    Garrett

  • Dirk,

    There are quite a few resources that describe addition of a UART instance to your setup on AM335x. I am attaching the application notes we have created in the past to help with this setup:

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

    6052.AM335x_Board_Porting_using_PRSDK.pdf

    Regards,

    Rahul

  • I checked the following things:

    Pinmux:

        PIN_UART1_RXD              = 0x0980U,  These are the same settings which i get if I use the pin mux tool
        PIN_UART1_TXD              = 0x0984U,

    icev2AM335x.c / function Board_moduleClockInit

        status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 0U, 0U);
        if(S_PASS == status)
        {
            status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 1U, 0U); <<< here the UART1 is activated
        }

    and here my small code to check the UART:

    normally I would expect that after start of the PROFINET application the Board_Init function has been called, but we call it to ensure the pin mux. removing this line has no effect.

        Board_STATUS boardCfg = BOARD_INIT_PINMUX_CONFIG;
        Board_init(boardCfg);

    now the UART is initialized and opened

        UART_Params_init(&params);

        params.baudRate = 19200;
        params.dataLength = 8;
        UartHandle = UART_open(1, &params);

    now I make a small loop sending the 0x55,0xAA to the UART. I cannot see any signal on the RS485 driver U28 where I can look at the TX line from the MCU to the RS485 driver.


        uint8_t txBuffer[]={0x55,0xAA};
        while (1)
        {
            UART_write(UartHandle, txBuffer, sizeof(txBuffer));/* Write API */
            OsWait_ms(100);
        }

    The function UART_Write is returning every time without any error.

    did I miss anything ?

    I hope that after installation of the PDK the library is compiled with the same sources of pinmux,...

    Cheers,

    Dirk

  • Dirk,

    I missed the fact that you are trying to use the DB9 connector which is used for CAN/Profibus. That connector on the board seems to be connect to PRU UART and not the SOC UART so this can`t be used as a general purpose UART since it needs to be programmed from the ICSS/PRU subsystem. 

    Here is the note from the AM335x ICEv2 HArdware user guide:

    http://www.ti.com/lit/ug/spruip3/spruip3.pdf

    Based on my understanding only UART3 instance has been brought out to a connector to interface with PC. The other UART that you can use is UART4. I came across a similar issue that was posted on E2E for this platform where a colleague had helped the user with enabling UART4. The user reported similar issues as you encountered using the DB9 connector that you indicated.

    https://e2e.ti.com/support/processors/f/791/t/678293?RTOS-TMDSICE3359-Changing-UART-instance#pi320966=3

    Hope this helps,

    Regards,

    Rahul

  • Rahul,

    I came to the same conclusion, but there is an explanation:

    the PROFIBUS pru firmware is using the UART for PROFIBUS communication. in this case the UART1 is blocked by the PRU.

    we are running the PROFINET solution, and PROFINET does not use the Uart because it's only using the ethernet peripheral.

    Two solutions:

    1. modify the pinmux file. this has the disadvantage that the pinmux file exists only once, so if you switch to PROFIBUS, you have to modify it once more

    2. it's possible to overwrite the pinmux registers for D15/D16 after call to board init with the correct signals.
    I did this (wrote 0 as function for the D15 with the debugger), and I could see the UART signals on the RS485 driver.

    I hope this solution is correct (at least if the PRU firmware is not using the UART)

    Cheers, Dirk