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.

C2000 Launchipad's SCI(UART) works oddly

Other Parts Discussed in Thread: CONTROLSUITE, LAUNCHXL-F28027

Hello.

I'm using C2000 launchpad. And trying to use Bluetooth module with SCI(UART) communication.

Before use the Bluetooth module, I did a test by Hyper terminal.

I find that Launchpad Tx function works well. But Rx is not.

As below SCIRXEMU & SCIRXBUF works properly.

But the SCIRXST (Receive ready flag) never changes.

I’m using

SCI_putDataBlocking()

SCI_getDataBlocking()

In the

C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_common\include\sci.h

C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_common\source\sci.c

What should I do?

 

  • This is my SCI initializing code. Please give me some advice.

     

    void scia_init()
    {
    
        CLK_enableSciaClock(myClk);
    
        // 1 stop bit,  No loopback
        // No parity,8 char bits,
        // async mode, idle-line protocol
        SCI_disableParity(mySci);
        SCI_setNumStopBits(mySci, SCI_NumStopBits_One);
        SCI_setCharLength(mySci, SCI_CharLength_8_Bits);
    
        // enable TX, RX, internal SCICLK,
        // Disable RX ERR, SLEEP, TXWAKE
        SCI_enableTx(mySci);
        SCI_enableRx(mySci);
        SCI_enableTxInt(mySci);
        SCI_enableRxInt(mySci);
    
    #if (CPU_FRQ_60MHZ)
        SCI_setBaudRate(mySci, SCI_BaudRate_9_6_kBaud);
    #elif (CPU_FRQ_50MHZ)
        SCI_setBaudRate(mySci, (SCI_BaudRate_e)13);
    #elif (CPU_FRQ_40MHZ)
        SCI_setBaudRate(mySci, (SCI_BaudRate_e)10);
    #endif
    
        SCI_enableFifoEnh(mySci);
        SCI_resetTxFifo(mySci);
        SCI_clearTxFifoInt(mySci);
        SCI_resetChannels(mySci);
        SCI_setTxFifoIntLevel(mySci, SCI_FifoLevel_Empty);
    //    SCI_enableTxFifoInt(mySci);
    
    
        SCI_resetRxFifo(mySci);
        SCI_clearRxFifoInt(mySci);
        SCI_setRxFifoIntLevel(mySci, SCI_FifoLevel_Empty);
    //    SCI_enableRxFifoInt(mySci);
    
    
        SCI_setPriority(mySci, SCI_Priority_FreeRun);
        SCI_enable(mySci);
    
        return;
    }

  • Hi,

    Which C2000 controller are you using? And the code that you're using is a custom one or a sample?

    Regards,

    Gautam

  • Thank you for your interest.

    I have started from Launchpad demo sample.

    Can you explain about C2000 controller? I just using C2000 launchpad, LAUNCHXL-F28027 and CCS v5.4.

     

    Regards.

    Hwang

  • Hi,

     Can you explain about C2000 controller?

    I would first like you to go through SCI basics:

    http://www.ti.com/lit/ug/sprugh1c/sprugh1c.pdf

    Regards,

    Gautam

  • I read it. But I can't know the controller.

    However, I can clarify the problem.

    By the Guide,

    RXRDY should set when SCIRXBUF get a data. But my code doesn't work that.

    This is why I'm very confused. Can you give me some advice?

     

    Regards,

    Hwang.

  • Hi,

    The above doc is F28027 compatible. If RXRDY is not setting even after your Bluetooth module has sent a data then  there seems to be only one issue; baudrate matching! I guess your BM will be set to 9600bps as default; so please go through your BM's specs and initialize F28027's baudrate properly.

    Regards,

    Gautam

  • I don't use the BM yet.

    I'm testing board's SCI(UART) function by PC(hyper terminal).

    The board can Tx data well. But Rx is not.

    I can observe the SCIRXBUF get the right data.

    But RXRDY never sets.

    In other words, Tx works well but Rx is not. In this case, the baudrate can be problem?

    Sorry to bother you.

    But I can't understand this problem.

     

    Regards,

    Hwang

  • Hi,

    If Tx is working fine and Rx is not  then Baudrate's not an issue. But there seems to be some issue with the Rx interrupt flag then. I'm attaching F28027 based SCI project:

    3247.sci_echoback.zip

    Just check this out and revert.

    Regards,

    Gautam

  • Thank you very much.

    Now it works fine.

    I have changed my code like yours,

    this

    test[j] = SCI_getDataBlocking(mySci);


    to 

     
    while(SCI_getRxFifoStatus(mySci) < SCI_FifoStatus_1_Word){
    }
    test[j] = SCI_getData(mySci);

    Thanks your help.

     

    Regards,

    Hwang

  • Congrats!

    Cheers,

    Gautam

  • I'm not sure if this is a related problem but I see a potential issue with the SCI_setTxFifoIntLevel() function which seems to be incorrectly modifying the SCIFFTX register rather than the SCIFFRX register. The line that concerns me is hilighted in yellow below:

    void SCI_setRxFifoIntLevel(SCI_Handle sciHandle, const SCI_FifoLevel_e fifoLevel)
    {
        SCI_Obj *sci = (SCI_Obj *)sciHandle;
    
    
        // clear the value
        sci->SCIFFTX &= (~SCI_SCIFFRX_IL_BITS);  // <--- This should be SCIFFRX I believe
    
        // set the bits
        sci->SCIFFRX |= fifoLevel;
    
        return;
    } // end of SCI_setRxFifoIntLevel() function
    Gautam, could this potential explain any issues with Tx and Rx not both working correctly in FIFO interrupt mode?  
    
    
    Cheers,
    Gord
  • Hello Gordon,

    Good finding! ^^

    Indeed it is a bug (TI member should note this in their bug file for next release).

    If SCI_setRxFifoIntLevel is called after SCI_setTxFifoIntLevel, then SCIFFTXIL will be cleared and usually never been set again because these functions usually are called only once in initialization.

    However in Hwang case, the TXFFIL bits are 0, so i think this doesn't influence the entire code.

    Best regards,

    Maria