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.

CCS/TMS320VC5502: UART First character missing

Part Number: TMS320VC5502

Tool/software: Code Composer Studio

Hi,

I use following code to print in UART-115200 baudrate

#include <stdio.h>
#include <csl.h>
#include <csl_pll.h>
#include <csl_gpio5502.h>
#include <csl_gpio5502dat.h>
#include <csl_gpio5502hal.h>
#include <csl_uart.h>
#include <csl_uarthal.h>
#define STR_LEN 25

char myBuf[24] = "This is simple UART test";
char end[2] = {0x0a,0x0d};
int receive[1];

UART_Setup mySetup = {
30, /* input clock freq */
133, /* baud rate */
UART_WORD8, /* word length */
UART_STOP1, /* stop bits */
UART_DISABLE_PARITY, /* parity */
UART_FIFO_DISABLE, /*DISABLE */
UART_NO_LOOPBACK, /* Loop Back enable */
};

void main()
{
unsigned int i,j;
CSL_init();
PLL_setFreq( 1, // PLL mode
0xF, // Multiply factor, Valid values are (multiply by)10
0, // Sysclk 0 Divide Down
1, // Sysclk1 Divider 150MHz
3, // Sysclk2 Divider 75MHz
3, // Sysclk3 Divider
0); // CLKOUT3(DSP core clock) divider 300MHz
UART_setup(&mySetup);
PGPIOEN0=0x000F;
PGPIODIR0=0x000F;
PGPIODAT0=0x0000;
while(1)
{
UART_write(myBuf,24,0);

PGPIODAT0=0x000F;
 for(j=0;j<1000;j++)
 for(i=0;i<10000;i++);
PGPIODAT0=0x0000;
for(j=0;j<1000;j++)
 for(i=0;i<10000;i++);
}
}

Above Program Always missing First Character 'T' -- Print as      his is simple UART testhis is simple UART testhis is simple UART testhis is simple UART testhis is simple UART test

 

if i am removing for loop delay, i got correct UART print as        This is simple UART testThis is simple UART testThis is simple UART testThis is simple UART testThis is simple UART test

 

Any mistakes in my program.

please help me to out.

 

Thanks

  • Hi Muneeswaran,

    I have some suggestions about your UART test program:

    1. Could you try to initialize UART as it is done in csl_uart_intc_example.c CSL example

        /* 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(status);
        }
    	else
    	{
    		printf("UART_init Successful\n");
    	}
    
        status = SYS_setEBSR(CSL_EBSR_FIELD_PPMODE,
                             CSL_EBSR_PPMODE_1);
        if(CSL_SOK != status)
        {
            printf("SYS_setEBSR failed\n");
            return (status);
        }
    
        /* 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(status);
        }
    	else
    	{
    		printf("UART_setup Successful\n");
    	}
    

    2. Could you add null termination to myBuf[24] for example:

    // char myBuf[24] = "This is simple UART test";
    
    char myBuf[25] = "This is simple UART test";
    .....
    myBuf[24] = '\0';

    3. If the issue still appears could you try to use UART_fputs instead of UART_write.

    Regards,

    Tsvetolin Shulev