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/LAUNCHXL-F28377S: Echoback code not working

Part Number: LAUNCHXL-F28377S

Tool/software: Code Composer Studio

I am using the following code to send serial data from Hyperterminal to the processor and receive it back on the HyperTerminal, after i press a key on the keyboard the same appears on the terminal after 5-10 secs and some of the data are also skipped. What is wrong?  

#include "F28x_Project.h"
void TX(int x);
int RX();
__interrupt void TX_ISR();
__interrupt void RX_ISR();
char a;
Uint16 x;
//
void main()
{
    char *msg;
    InitSysCtrl();
    InitGpio();


    DINT;
    PieCtrlRegs.PIECTRL.bit.ENPIE=1;
    InitPieCtrl();

    IER=0;
    IFR=0;

    InitPieVectTable();

    EALLOW;
    PieVectTable.SCIB_TX_INT=&TX_ISR;
    PieVectTable.SCIB_RX_INT=&RX_ISR;
    ClkCfgRegs.LOSPCP.bit.LSPCLKDIV=1;
    EDIS;

    EALLOW;
    GPIO_SetupPinMux(87, GPIO_MUX_CPU1, 5);
    GPIO_SetupPinOptions(87, GPIO_INPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(86, GPIO_MUX_CPU1, 5);
    GPIO_SetupPinOptions(86, GPIO_OUTPUT, GPIO_ASYNC);
    EDIS;

//initialisation//
  ScibRegs.SCICCR.all = 0x0007;
  ScibRegs.SCICTL1.all = 0x0003;
  ScibRegs.SCIHBAUD.all = 0x0002;
  ScibRegs.SCILBAUD.all = 0x008B;
  ScibRegs.SCICTL2.all = 0x0003;
  ScibRegs.SCICTL2.bit.TXINTENA = 1;
  ScibRegs.SCICTL2.bit.RXBKINTENA = 1;
  ScibRegs.SCICTL1.all = 0x0023;
  //ScibRegs.SCICCR.bit.LOOPBKENA=1;
 //fifo initialisation
  ScibRegs.SCIFFTX.all = 0xE040;
  ScibRegs.SCIFFRX.all = 0x2044;
  ScibRegs.SCIFFCT.all = 0x0;

  PieCtrlRegs.PIECTRL.bit.ENPIE = 1;   // Enable the PIE block
  PieCtrlRegs.PIEIER9.bit.INTx3 = 1;   // PIE Group 9, INT1
  PieCtrlRegs.PIEIER9.bit.INTx4 = 1;
  IER = 1;                         // Enable CPU INT

  EINT;

  EALLOW;
  GpioCtrlRegs.GPADIR.bit.GPIO12=1;
  GpioCtrlRegs.GPADIR.bit.GPIO13=1;
  EDIS;

  while(1)
  {
     if(ScibRegs.SCIRXST.bit.RXRDY==1)
       {
        x=ScibRegs.SCIRXBUF.all;
        TX(x);
     }
  }


}

void TX(int a)
{
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    ScibRegs.SCITXBUF.all =a;

}

int RX()
{   int ReceivedChar;
    ReceivedChar = ScibRegs.SCIRXBUF.all;
    return ReceivedChar;
}

__interrupt void TX_ISR()
{

    ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;   // Clear SCI Interrupt flag
    PieCtrlRegs.PIEACK.all|=0x100;

}


__interrupt void RX_ISR()
{
    //ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1;   // Clear Overflow flag
    ScibRegs.SCIFFRX.bit.RXFFINTCLR=1;   // Clear Interrupt flag

    PieCtrlRegs.PIEACK.all|=0x100;
}

  • Rajesh,

    Please compare your code to the following known working code at:

    C:\ti\c2000\C2000Ware_<version>\device_support\f2837xs\examples\cpu1\sci_echoback\cpu01

    Also, check to make sure that the baud rate on the Hyper-terminal matches to what you are using in your code.

    It sounds like you have your code working, except for the delay issue.  In general, we do not review or debug user code, but we will provide assistance to you with specific issues relating to our devices and development tools. This includes clarifying the behavior of any bit, register, or features when designing with our devices. Please note that all peripherals have example code in C2000Ware. As recommended above, we suggest comparing your code to the example code to determine where the problem may exist. It is recommended to follow standard and logical debugging techniques. Please continue to debug your code and feel free to use this forum to ask specific questions. The more specific the question, the better we can assist you.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken

  • The baud rate is alright as i am able to transmit signals and the characters sent are the same as received on the terminal, and also i have checked on oscilloscope too. The example code that you suggested isn't working. When I run it, it doesn't give any output. I also tried to see how fast RXRDY flag changes and saw that it sometimes takes 15secs or more. Isn't is supposed to get cleared after I read the SCIRXBUF? 

  • Rajesh,

    Please note that the example code in your case is for reference and comparison.  This code uses SCI-A where GPIO28 is SCI_A-RXD and GPIO29 is SCI_A-TXD.  These SCI-A signals are not pinned out on the F28377S LaunchPad, so to test the example code you would need to modify it for SCI-B or SCI-C along with the GPIO.  Also, if using SCI-D (GPIO84 and GPIO85) you should be able to use the FTDI USB connection with the terminal feature in CCS.  This should be relatively easy to change.

    Yes, you are correct - RXRDY is cleared by a reading of the SCIRXBUF register (and also by a software reset or system reset).  When a new character is ready to be read from the SCIRXBUF register, this bit is set and a receiver interrupt is generated only if RXBKINTENA in SCICTL2 is a 1.

    I am not sure why you are experiencing such a long delay.  Could you please try modifying the example code for your LaunchPad and check if you are experiencing the same delay?  (Only modify for a different SCI and GPIO, but do not make any other changes to the code).

    - Ken

  • I did change the settings of the echoback example code to scib by changing all the scia to scib and the pins 86 and 87 are used with mux value of 5, but still i see nothing on the hyperterminal. Please help. And in the code that I have posted, i checked both channels using scope and keeping one key pressed and found that data chain is sent from the computer but the processor sends back the data only sometimes. The number of sent data and echoed back data are not same.  

  • Rajesh,

    I have the echoback example working with SCI-A on the F28377S LaunchPad.  SCI-A (GPIO84 and GPIO85) is communicating through the FTDI USB connection and I am using the terminal feature in CCS.  You need to make the following modifications to the GPIO:

    //   GPIO_SetupPinMux(28, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinMux(85, GPIO_MUX_CPU1, 5);
    //   GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
       GPIO_SetupPinOptions(85, GPIO_INPUT, GPIO_PUSHPULL);
    //   GPIO_SetupPinMux(29, GPIO_MUX_CPU1, 1);
       GPIO_SetupPinMux(84, GPIO_MUX_CPU1, 5);
    //   GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);
       GPIO_SetupPinOptions(84, GPIO_OUTPUT, GPIO_ASYNC);

    Next, in your project you need to add "_LAUNCHXL_F28377S" as a predefined symbol in the project properties.  In CCS right-click on your project and select 'Properties".  Then under C2000 Compiler -> Advanced Options -> Predefined Symbols add _LAUNCHXL_F28377S.  For more details, see section 4.4 in the F28377S LaunchPad User's Guide:

    http://www.ti.com/lit/sprui25

    Now that this example is working, you can use it as a reference for comparing your code to.

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

     - Ken