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.

VC5504 UART

Other Parts Discussed in Thread: TMS320C5505

Hi:

I am having problems sending data using the VC5504 UART. The UART is programmed for 8 bit data, 9600 baud, and no flow control. Only Rx interrupt is enabled with FIFO trigger level of 1 byte. All the other interrupts are disabled. What 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. Another thing that I observed is that even though flow control is disabled and I am expecting both CTS and RTs to be at 0.0V, I am actually observing the RTS line to be at 2.0V and the CTS line is at 0.0V. Could you please help? I don't know why I am not seeing any activity on the Tx. line. I have configured the UART as below.

Thanks a lot.

Cheers,

Mushtaq

void Uart_Config()
{
 int i, divisor;

 //Enable Clock to UART.
 PCGCR1 &= 0xfffb; //Set bit 2 to 0 to enable uart clock.

 //Set parallel port to mode 1, i.e. uart,i2s2,i2s3, and spi. (bits 14-12)
 //EBSR |= 0x1000; This is done in pwron.c

 //Reset uart. CAUTION: This resets uart, spi, i2s2, and i2s3.
 PSRCR = 0x0050; //Count of system clock cycles for which SW reset is asserted in the next instruction.
 PRCR  &= 0x0080;     // Reset peripheral group four -- uart, spi, i2s2, and i2s3 (bit 7). 
 for(i=0;i<50;i++){}; //Wait.
 
 *(ioport unsigned int *)URPECR = 0x1fff;  //  disable UART Mushtaq 011911 uart Reset uart Tx and Rx. 

 //Mushtaq 011911 uart This is for testing.
 *(ioport unsigned int *)URLCR = 0x03;  // 8-bit, no parity checks, 1 stop

//Mushtaq 011911 uart Changed for c5504.CLOCK_CYCLES_PER_UART_SAMPLE changed in sysdef.h
 //divisor = (CLOCK_CYCLES_PER_UART_SAMPLE + 8) / 16;
 divisor = (CLOCK_CYCLES_PER_UART_SAMPLE) / 16; //Mushtaq 011911 Data sheet formula is (CPU clock)/(Baud rate *16)
 //mytemp = divisor;

 *(ioport unsigned int *)URDLL = divisor & 0xFF; //lower byte of divisor.
 *(ioport unsigned int *)URDLM = (divisor >> 8) & 0xFF; //upper byte of divisor.
 
// *(ioport unsigned int *)URIER = 0x07;  // enable all interrupts (line status, xmit, recv)
 *(ioport unsigned int *)URIER = 0x01;  // enable only recv interrupt
 
 /*
  URFCR FIFO Control Register
  | 76 | 54 | 3 | 2 | 1 | 0 |
    10   00   1   1   1   1
     |    |   |   |   |   |
     |    |   |   |   |   FIFO enabled
     |    |   |   |   Clears the receiver FIFO pointer
     |    |   |   Clears the transmitter FIFO pointer
     |    |   1   Required to always write 1 to this bit
     |    Reserved  
     Receiver FIFO trigger level.  Set to interrupt CPU every 8 bytes.
 */
// *(ioport unsigned int *)URFCR = 0x8F;
//Mushtaq 011911 uart Changed for c5504.
 //*(ioport unsigned int *)URFCR = 0x0F;  //  change recv trigger level to 1 byte.
 *(ioport unsigned int *)URFCR = 0x01;  //  FIFO must be enabled first.
 *(ioport unsigned int *)URFCR = 0x07;  // Rx trig 1 byte, no dma, FIFOs clear, counters clear.

 /*
  URLCR Line Control Register
 */
 *(ioport unsigned int *)URLCR = 0x03;  // 8-bit, no parity checks, 1 stop

 /*
  URMCR Modem Control Register
 */
 *(ioport unsigned int *)URMCR = 0x0000;  // No flow, no loopback mode, and RTS disabled

//Mushtaq 011911 uart Output pin PIO2 from BT module is connected to GPIO15. Set GPIO15 as input.
 *(ioport unsigned int *)IODIR1 &= ~IN_BT_TO_DSP;  //  set the GPIO15 direction to input

//Mushtaq 011911 uart Set GPIO16 as input. Because of mistake on schematic GPIO16 is connected to uart CTS.
 *(ioport unsigned int *)IODIR2 &= ~IN_GPIO16;  //  set the GPIO16 direction to input

 i = *(ioport unsigned int *)URRBR; //Mushtaq 011911 uart Clear any preexisting characters.
 
}

  • Mushtaq,

    I got your rar file. We will switch to email.

    Regards.

    Steve

  • Hello,

    I am having the same problem with TMS320C5505:

     

    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");
        }

    // Enable the UART Events
        status = UART_eventEnable(hUart, CSL_UART_XMITOR_REG_EMPTY_INTERRUPT);
        if(status != CSL_SOK)
        {
            printf("UART_eventEnable Failed\n");
        }

    }

     

     

    void uart_txIsr(void)
    {

    status1 = UART_write( hUart,Buff_tx_uart,2,0);

    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);

    }

  • Hello,

    I have the same problem which is described above. My UART module isn't working even using the CSL demo code which is shown below.

     

    #include <stdio.h>

    #include <csl.h>

    #include <csl_uart.h>

     

    //---------Global constants---------

    /* String length to be received and transmitted */

    #define STR_LEN        80

     

    //---------Global data definition---------

    /* Buffer to be copied to clip board and sent to UART 

       using terminal emulator program 

    */

    char clipboardBuf[] = {

    " <BEGIN>The quick brown fox jumped over lazy dog. This is simple UART test<END>"

    };

     

    /* User buffer that receives data */

    char myBuf[STR_LEN];

     

    /* UART setup structure */

    UART_Setup mySetup = {

       75,  /* input clock freq */

       UART_BAUD_4800, /* baud rate */

       UART_WORD8, /* word length */

       UART_STOP1, /* stop bits */

       UART_DISABLE_PARITY, /* parity */

       UART_FIFO_DISABLE, /*DISABLE */

       UART_NO_LOOPBACK,   /* Loop Back enable */

    };

     

    //---------main routine---------

    void main()

    {

        /* Loop counter and error flag */

        Int16 i, error = 0;

     

        /* Initialize CSL library */

        CSL_init();

     

        /* Configure UART registers using setup structure */

        UART_setup(&mySetup);

     

        /* UART receiver reads data from PC COM port */

        if (UART_read(myBuf, STR_LEN, 0) == FALSE) {

           error = 1;

        }

        else {

           

           /* UART transmitter write data to PC COM port */

           if ((UART_write(myBuf, STR_LEN, 0)) == FALSE)

               error = 1;

        }

       

        /* Verify the recevied data for correctness */

        for (i = 0; i < STR_LEN-1; i++) {

           if (myBuf[i] != clipboardBuf[i]) {

               error = 1;

               break;

           }

        }

       

        /* Display PASS/FAIL status based on error flag */

        if (error)

           printf("\nTEST FAILED\n");

        else

           printf("\nTEST PASSED\n");

    }

    I have monitored the TX line and nothing happens when the UART_write is called. In addition, when I send data to DSP, the UART peripheral isn't detecting data. I would like some help. 
    Thanks.
    Fred

  • Hi Fredico,

    Try tu put 

    75000000,  /* input clock freq */

    rather than

    75,  /* input clock freq */


    Nicolas

  • Hello Idoia,

    I happen to have the same problem as described by you.There is no activity on the Tx line even though the code is writing data to the THR register.

    It's been long since you posted this.I would be glad to know if you have come across any solution for this.

    Thanks in advance