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.

LAUNCHXL-F2800137: printf() affecting excecution

Part Number: LAUNCHXL-F2800137


Tool/software:

I am testing SCI communication on the LAUNCHXL-F2800137.

I have noticed that when using a printf() statement it will affect how the program executes.

Including the following printf() statement will prevent SCI_readCharBlockingFIFO() from reading more characters.

if( xMBPortSerialInit( 0, 115200, 8, MB_PAR_NONE ) == FALSE )
    {
        printf("error: com init failed");
    }
    else
    {
        /* Enable the transmitter. */ 
        vMBPortSerialEnable( TRUE, FALSE);
        //Block Execution
        for (;;)
        {
            uint16_t receivedChar = SCI_readCharBlockingFIFO(SCIA_BASE);
            
            uint16_t rxStatus = SCI_getRxStatus(SCIA_BASE);
            if((rxStatus & SCI_RXSTATUS_ERROR) != 0)
            {
                //
                //If Execution stops here there is some error
                //Analyze SCI_getRxStatus() API return value
                //
                ESTOP0;
            }
            printf("%c\n", receivedChar);
            SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar);
        }
    }

SCI_writeCharBlockingFIFO() with the printf() statement will stop at "1ò" when the computer sends "123".

Removing the printf() statement will allow the code to run as expected.

    if( xMBPortSerialInit( 0, 115200, 8, MB_PAR_NONE ) == FALSE )
    {
        printf("error: com init failed");
    }
    else
    {
        /* Enable the transmitter. */ 
        vMBPortSerialEnable( TRUE, FALSE);
        //Block Execution
        for (;;)
        {
            uint16_t receivedChar = SCI_readCharBlockingFIFO(SCIA_BASE);
            
            uint16_t rxStatus = SCI_getRxStatus(SCIA_BASE);
            if((rxStatus & SCI_RXSTATUS_ERROR) != 0)
            {
                //
                //If Execution stops here there is some error
                //Analyze SCI_getRxStatus() API return value
                //
                ESTOP0;
            }
            //printf("%c\n", receivedChar);
            SCI_writeCharBlockingFIFO(SCIA_BASE, receivedChar);
            //fflush(stdout);
        }
    }

Removing the printf() statement will allow echo back "123" when sending "123".

Why does printf() affect the execution?

Thanks,

Allan