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.

TMS320C5505 UART Transmission

Hello,

 

I am observing is that there is no activity on the Tx line even though the code is writing data to the THR register. Also the code monitors bit 6 of the LSR register to ensure that both the Tx FIFO and the Tx shift register are empty. The Tx line remains at 3.3V.

 

Which is the solution?

 

CSL_UartSetup mySetup =
{

// Input clock freq in MHz
    100000000,
    // Baud rate
    38400,
    // Word length of 8
    CSL_UART_WORD8,
    // To generate 1 stop bit
    0,
    // Disable the parity
    CSL_UART_DISABLE_PARITY,
    // Enable trigger 14 fifo
    CSL_UART_FIFO_DMA1_DISABLE_TRIG14,
    // Loop Back enable
    CSL_UART_NO_LOOPBACK,
    // No auto flow control
    CSL_UART_NO_AFE ,
    // No RTS
    CSL_UART_NO_RTS ,

};

void Init_Uart(void)
{
    CSL_UartIsrAddr    isrAddr;
    CSL_Status         status;
    Uint32             sysClk;

sysClk = getSysClk();

    mySetup.clkInput = sysClk;

    // Loop counter and error flag
    status = UART_init(&uartObj,CSL_UART_INST_0,UART_INTERRUPT);
    if(CSL_SOK != status)
    {
        printf("UART_init failed error code %d\n",status);
        return;
    }
    else
    {
        printf("UART_init Successful\n");
    }

    // Handle created
    hUart = (CSL_UartHandle)(&uartObj);

    // Configure UART registers using setup structure
    status = UART_setup(hUart,&mySetup);
    if(CSL_SOK != status)
    {
        printf("UART_setup failed error code %d\n",status);
        return;
    }
    else
    {
        printf("UART_setup Successful\n");
    }

    // Configure and Register the UART interrupts
   
    isrAddr.tbeiAddr = uart_txIsr;
   

// Configuring Interrupt
    IRQ_plug (UART_EVENT, &UART_intrDispatch);



    Buff_tx_uart[0] = 'L';
    Buff_tx_uart[1] = 0xAA;


    // Enabling Interrupt
    IRQ_enable(UART_EVENT);


    // Set the UART callback function
     status = UART_setCallback(hUart,&isrAddr);
    if(status != CSL_SOK)
    {
        printf("UART_setCallback Failed\n");
    }

}

 

 

void uart_txIsr(void)
{

status = UART_eventDisable(hUart, CSL_UART_XMITOR_REG_EMPTY_INTERRUPT);

}

interrupt void UART_intrDispatch(void)
{
    Uint16 eventId = 0;

    IRQ_disable(UART_EVENT);

    /* Get the event Id which caused interrupt */
   
   
  eventId = UART_getEventId(hUart);


    return;
}

 

void main()

{

       status = UART_eventEnable(hUart, CSL_UART_XMITOR_REG_EMPTY_INTERRUPT);

        UART_write( hUart,Buff_tx_uart,2,0);

}

 

  • Same problem here, but mine example runs for some time and then just stops executing the uart_txIsr although the FIFO and the Tx shift register are empty..

  • It seems at I wasn't having access at the UART registers. I write a 0x0000 through the Code Composer Studio, then I configure the UART but the value of the registers remain in 0x0000.

    If I try to do a polling transmission:

    The program gets waiting for the change of the THR in that line in red:

    CSL_Status UART_fputs(CSL_UartHandle hUart, const Char* pBuf, Uint32 timeout)
    {
        Uint32 TimeOut  = timeout;
        CSL_Status status = CSL_SOK;

        if( NULL == hUart )
         {
             return CSL_ESYS_BADHANDLE;
         }

        if( NULL == pBuf )
         {
            return CSL_ESYS_INVPARAMS;
         }

        CSL_FINST(hUart->uartRegs->LCR, UART_LCR_DLAB, DLABON);       

        if( 0 != timeout )
        {
            while('\0' != *pBuf)
            {
                while( ( !UART_getXmitHoldRegEmptyStatus(hUart) ) && TimeOut-- );
                if (0 == TimeOut)
                    return CSL_EUART_TIMEOUT;
                CSL_FSET(hUart->uartRegs->THR, 7, 0, (*pBuf)&CSL_UART_THR_DATA_MASK);           
                pBuf++;           
                TimeOut  = timeout;
            }
        }
        else
        {
            while( '\0' != *pBuf )
            {
                while(!UART_getXmitHoldRegEmptyStatus(hUart));
                CSL_FSET(hUart->uartRegs->THR, 7, 0, (*pBuf)&CSL_UART_THR_DATA_MASK);           
                pBuf++;                       
            }
        }

  • The pin  tx of the UART doesn't move when I try to write to it, even in polled mode.

    I initialize the UART pins by multiplexing:

    CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_PPMODE, MODE1); // UART

    Is there something else I should do?

    Thanks a lot,

  • I got it!

    I used software based on the csl_gpt_example, where there is the function: Uint32 getSysClk(void), which returns the value; litteraly this comment:

    /* Return the value of system clock in KHz */
        return(sysClk/1000);

    As I used this function, at from the beginning from that module, when I added some code for the Uart based on the csl_uart_polled_exampl; it was a call to the same function:

    Uint32 getSysClk(void), so I used the call to the gpt module, but if you look it up better, it has the same name and the same output comment but now the frequency is given in Hz instead of in KHz:

    /* Return the value of system clock in KHz */
        return(sysClk);

    That is why with the first function the Uart was imposible of being configured.