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.

Problems getting both UARTs (UART 0 & UART1) working together.

Hi!

I have problem trying to use UART0 and UART1 together on DM6437. First UART0 is intended to use on RS-232 app and UART1 for a RS-485 app (trhough SAE-J1708 implementation).

I used UART0 alone and is working well. Then I used UART1 alone and works fine. But when both Uart's intances are togeher and run my code on chip, UART0 Reception doesn't work it seems to be disabled. I have UART0 Tx as task, same for UART0 Rx with same (and the highest) priority. UART1 Tx and UART1 Rx are separeted tasks (with same pririty).

I am doing the next things:

-First UART0 and UART1 devices are created

/* Uart0 Driver*/
bios.UDEV.create("UART0");
bios.UDEV.instance("UART0").fxnTableType = "IOM_Fxns";
bios.UDEV.instance("UART0").initFxn = prog.extern("UART0_INIT");
bios.UDEV.instance("UART0").fxnTable = prog.extern("UARTMD_FXNS");
bios.UDEV.instance("UART0").params = prog.extern("Uart0_DevParams");
bios.UDEV.instance("UART0").deviceId = 0;

/* Uart1 Driver*/
bios.UDEV.create("UART1");
bios.UDEV.instance("UART1").fxnTableType = "IOM_Fxns";
bios.UDEV.instance("UART1").initFxn = prog.extern("UART1_INIT");
bios.UDEV.instance("UART1").fxnTable = prog.extern("UARTMD_FXNS");
bios.UDEV.instance("UART1").params = prog.extern("Uart1_DevParams");
bios.UDEV.instance("UART1").deviceId = 1;

With Dev params as:

/**< Default UART0 Device Parameters, using PSP Drivers */
UARTMD_DevParams Uart0_DevParams =
                    {                        
                        PSP_OPMODE_INTERRUPT,     ///< Driver operation mode                        
                        TRUE,                     ///< Sync mode enabled                         
                        PSP_UART_MODULE_CLOCK,    ///< Default input module clock                        
                        NULL                      ///< Edma handle
                    };

/**< Default UART1 Device Parameters, using PSP Drivers */
UARTMD_DevParams Uart1_DevParams =
                    {                        
                        PSP_OPMODE_INTERRUPT,     ///< Driver operation mode                        
                        TRUE,                     ///< Sync mode enabled                         
                        PSP_UART_MODULE_CLOCK,    ///< Default input module clock                        
                        NULL                      ///< Edma handle
                    };

- Next EDMA3 is initialized:

extern EDMA3_DRV_Handle hEdma;
extern EDMA3_DRV_Result edma3init();

EDMA3_DRV_Result    edmaResult      = 0;

Int16 EDMA3_init(void)
{
    /* Initialize EDMA3 */
    if(NULL == hEdma)                //hEdma defined in edma library
    {
        edmaResult = edma3init();
        if (edmaResult != EDMA3_DRV_SOK)
        {
            // EDMA Error
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }
    return FALSE;
}

- Then UART0 and UART1 instances are created:

// GIO_Handle objects for Input and Output on UART0
GIO_Handle hUart0_OUT, hUart0_IN;

void UART0_INIT()
{
    if(NULL != hEdma) //hEdma defined in edma library
    {
        Uart0_DevParams.hEdma = hEdma;
    }
}

void UART1_INIT()
{
    if(NULL != hEdma)     //hEdma defined in edma library
    {
        Uart1_DevParams.hEdma = hEdma;
    }
}

Int16 UART_InitUart0Module(void)
{

    Int32               echoTskStatus   = 0;
    GIO_Attrs           gioAttrs        = GIO_ATTRS;
...
    // CREATE UART 0 OBJECT
    hUart0_OUT = GIO_create("/UART0", IOM_OUTPUT, NULL, NULL, &gioAttrs);
    hUart0_IN  = GIO_create("/UART0", IOM_INPUT, &echoTskStatus, NULL, &gioAttrs);
      
    if( (NULL == hUart0_IN)||(NULL == hUart0_OUT) )
    {
        return FALSE;
    }

    // In case of UART0: HW flow control is activated
    //ACTIVATE HARDWARE FLOW CONTROL FOR UART0
    Uart0_FlowControl.fcType  = PSP_UART_FC_TYPE_HW;
    Uart0_FlowControl.fcParam = PSP_UART_SWFC_NONE;

    if ( GIO_control (hUart0_OUT, PSP_UART_IOCTL_SET_FLOWCONTROL, &Uart0_FlowControl) != IOM_COMPLETED )
        return FALSE;
    if ( GIO_control (hUart0_IN,  PSP_UART_IOCTL_SET_FLOWCONTROL, &Uart0_FlowControl) != IOM_COMPLETED )
        return FALSE;

....

}

Int16 UART_InitUart1Module(void)
{

    Int32               echoTskStatus   = 0;
    GIO_Attrs           gioAttrs        = GIO_ATTRS;
   
    // CREATE UART 1 OBJECT
    hUart1_OUT = GIO_create("/UART1", IOM_OUTPUT, NULL, NULL, &gioAttrs);
    hUart1_IN  = GIO_create("/UART1", IOM_INPUT, &echoTskStatus, NULL, &gioAttrs);
    
    if( (NULL == hUart1_IN)||(NULL == hUart1_OUT) )
    {
        return FALSE;
    }

    // In case of UART1: Baud rate is set to 9600
...

}

The PLL settings for both UARTs are OK. I don't know what's happening or what is wrong.

Code Composer Studio V. 3.3.82.13

Code Generation Tools V. 6.1.20

BIOS V. 5.31.09

dvsdk 1_01_00_15 and psp drivers 1_00_02_00

  • Jhaeri,

    This thread is basically a continuation of http://e2e.ti.com/support/embedded/bios/f/355/t/100010.aspx#572022

    At this point, it appears that:

    • You are still running into issues when two UARTs are used

    • You have had some problems in getting UART1/UART0 alone working. Later you found out that because of an hardware related issue, UART1 was unable to receive the data. Now with the PSP example, you are able to run both UARTs independently. But when both are used together, then UART0 is not at all receiving any data. Since we do not have the setup to test this scenario, we have made a couple of suggestions in the other post.

    • It now looks like that the issue is related to your board (Since it is a custom board).

    To get a further response, I have moved this new thread from the BIOS forum over to the DM64xx forum.

    Dave

  • to debug, can you run it without BIOS to see UART0 and UART1 work?

    BR,

    Viet

  • Hi!

    David,

    You're right in your comments. In respect to suggestions that you have made in the previous post, I say:

    Which gpio pins are you using?.

    Have you tried building/using only UART1 instance and get it working? i.e, Test UART1 alone, both RX and TX. If not done, please try this. This is just to isolate the problem.

     Also, try configuring both the UART’s in polled mode and check its behavior!. And, when you are using both UART’s make sure the Power up settings for UART0 is done appropriately.

    Respect to GPIO pins we are using standalone GPIO for UART0 & UART1 and these are:

    For UART1 :

    HECC_RX/TINP1L/URXD1/GP[56] ( K4)

    HECC_TX/TOUT1L/UTXD1/GP[55] ( L4)

    For UART0 :

    URXD0/GP[85] ( L2)

    UTXD0/GP[86] ( K3)

    UCTS0/GP[87] ( L1)

    URTS0/PWM0/GP[88] ( L3)

    PINMUX1 configured as: TIM1BK ( 10b ) for UART1, UR0FCBK ( 01b) for UART0 flow control, UR0DBK ( 1b) for UART0 Data Mode.

    - I tested UART0 alone and works fine (Tx and Rx). I have built/used UART1 instance and works well (Tx and Rx), the problem in our hardware was solved.

    - Then I have cofigured both UARTs in polled mode and the same problem arises, UART0 reception is disabled.

    - Power up settings for UART0 is done appropriately, same for UART1.

    The last test that I did, was:

    -- In .tci file :
    /* Uart0 Driver*/
    bios.UDEV.create("UART0");
    bios.UDEV.instance("UART0").fxnTableType = "IOM_Fxns";
    bios.UDEV.instance("UART0").initFxn = prog.extern("UART0_INIT");
    bios.UDEV.instance("UART0").fxnTable = prog.extern("UARTMD_FXNS");
    bios.UDEV.instance("UART0").params = prog.extern("Uart0_DevParams");
    bios.UDEV.instance("UART0").deviceId = 0;
    
    /* Uart1 Driver*/
    bios.UDEV.create("UART1");
    bios.UDEV.instance("UART1").fxnTableType = "IOM_Fxns";
    bios.UDEV.instance("UART1").initFxn = prog.extern("UART1_INIT");
    bios.UDEV.instance("UART1").fxnTable = prog.extern("UARTMD_FXNS");
    bios.UDEV.instance("UART1").params = prog.extern("Uart1_DevParams");
    bios.UDEV.instance("UART1").deviceId = 1;
    
    -- Initialization params and functions are:
    ------------------------------------------------------------
    UARTMD_DevParams Uart0_DevParams =
                         {
                             PSP_OPMODE_INTERRUPT,     /** Driver operation mode */
                             TRUE,                                               /** Sync mode enabled */
                             PSP_UART_MODULE_CLOCK, /** Default input module clock */
                             NULL                                                /** Edma handle */
                         };
    
    UARTMD_DevParams Uart1_DevParams =
                         {
                              PSP_OPMODE_INTERRUPT,     /** Driver operation mode */
                             TRUE,                                                /** Sync mode enabled */
                             PSP_UART_MODULE_CLOCK, /** Default input module clock */
                             NULL                                                /** Edma handle */
                         };
    
    void UART0_INIT()
    {
           if(NULL != hEdma)            //hEdma defined in edma library
          {
     Uart0_DevParams.hEdma = hEdma;
          }
    }
    
    void UART1_INIT()
    {
           if(NULL != hEdma)         //hEdma defined in edma library
          {
                    Uart1_DevParams.hEdma = hEdma;
           }
    }

    I only let for UART1 the device initialization in .tci file and UART1_INIT() initialization function and Uart1_DevParams structure, no more code for UART1 or task or other resources related to UART1, the same problem for UART0 reception still arises. 

    The next test is upgrade our project to dsp/bios 5.33.06 version, dvsdk 1.11.00, pspdrivers 1.10.03 and code composer 3.3 since that in another post a person has obtained both UARTs working together using such pspdrivers version. We are going to check our hardware very, very well to discard some problem.

     Thanks!

  • Hi! 

    Viet, 

    I am going to do what you suggest. I will say you what happen later.

    Thanks

    Best regards, 

    Jhaeri