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.

TMS320F28034: SCIA issue

Part Number: TMS320F28034

Hi expert,

this is the issue of SCI receive. the host which sent data is another MCU, and also checked with PC. The issue is always.

After we initialize the configuration of SCIA after power-on, we will encounter that sometimes the data cannot be received normally. At this time, the data can be received normally after initializing the configuration again. This phenomenon does not occur on every board. Some boards sometimes appear, which is quite confusing.
We check the SciaRegs.SCIFFRX.bit.RXFFST flag at a time of 200us to determine whether there is data to be received.
After the DSP is powered on, the SciaRegs.SCIFFRX.bit.RXFFST is checked in a 200us cycle, sometimes the "if( SciaRegs.SCIFFRX.bit.RXFFST != 0 )" cannot be checked.

here I attached the initialized code.

3513.SCI.c
以下是初始化程序(初始化为接收):
initial to receiver
void SCIAGPIOInit(void)
{
       EALLOW;
       
       //GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1;     //use as Epwm4A    ----ZCLK
       //GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 0;          //use as output        ----ZCRRSET
       //GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
       //GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0;          //use as output        ----ZTXEN
       //GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
       
       GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0;       // Enable pull-up for GPIO28 (SCIRXDA)
       GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;    // Enable pull-up for GPIO29 (SCITXDA)
       GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1;     // Configure GPIO28 for SCIRXDA operation
       GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1;     // Configure GPIO29 for SCITXDA operation
       
       /*
       PieVectTable.SCIRXINTA = &SCIARxErrDeal;
       PieCtrlRegs.PIEIER9.bit.INTx1=1;     // PIE Group 9, INT1
       IER |= 0x100; // Enable CPU INT
    */
       EDIS;
}

void SCIARxInit(void)
{
       EALLOW;
       
       // Note: Clocks were turned on to the SCI peripheral in the InitSysCtrl() function
       SciaRegs.SCICTL1.bit.SWRESET = 0;
       SciaRegs.SCIFFTX.all=0xE040;
       SciaRegs.SCIFFRX.all=0x2044;
       SciaRegs.SCIFFCT.all=0x0;
       
       SciaRegs.SCICCR.all =0x0067;   // 1 stop bit,  No loopback 
       // Even parity,8 char bits,
       // async mode, idle-line protocol
       //SciaRegs.SCICTL1.all =0x0001;//0x0041;//0x0043;     //Enable RX ERR
       //SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK, 
       // Disable RX ERR, SLEEP, TXWAKE
       //SciaRegs.SCICTL2.all =0x0003; 
       //SciaRegs.SCICTL2.bit.TXINTENA =0;
       //SciaRegs.SCICTL2.bit.RXBKINTENA =1;
       
       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x00C2;  // 9600 bps
       //SciaRegs.SCILBAUD    =0x0061;  // 19200 bps
       //SciaRegs.SCILBAUD    =0x0030;  // 38400 bps
       switch(SCIABaudSet)
       {
           case 0:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x00C2;  // 9600 bps
                     break;
        case 1:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x0061;  // 19200 bps
                     break;
        case 2:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x0030;  // 38400 bps
                     break;
        default:break;
       }

       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x0060;  // 19200 bps

       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x000E;  // 125K bps
       
       SciaRegs.SCICTL1.bit.RXENA = 1;
       SciaRegs.SCICTL1.bit.TXENA = 0;
       SciaRegs.SCICTL1.bit.SWRESET = 1;
       //SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset 
       
       EDIS;
}
void SCIATxInit(void)
{
       EALLOW;
       
       // Note: Clocks were turned on to the SCI peripheral in the InitSysCtrl() function
       SciaRegs.SCICTL1.bit.SWRESET = 0;
       SciaRegs.SCIFFTX.all=0xE040;
       SciaRegs.SCIFFRX.all=0x2044;
       SciaRegs.SCIFFCT.all=0x0;
       
       SciaRegs.SCICCR.all =0x0067;   // 1 stop bit,  No loopback 
       // Even parity,8 char bits,
       // async mode, idle-line protocol
       //SciaRegs.SCICTL1.all =0x0002;   //enable Tx  cls  Rx
       //SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK, 
       // Disable RX ERR, SLEEP, TXWAKE
       //SciaRegs.SCICTL2.all =0x0002; 
       //SciaRegs.SCICTL2.bit.TXINTENA =1;
       //SciaRegs.SCICTL2.bit.RXBKINTENA =0;
       
       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x00C2;  // 9600 bps
       //SciaRegs.SCILBAUD    =0x0061;  // 19200 bps
       //SciaRegs.SCILBAUD    =0x0030;  // 38400 bps
       switch(SCIABaudSet)
       {
           case 0:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x00C2;  // 9600 bps
                     break;
        case 1:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x0061;  // 19200 bps
                     break;
        case 2:
                SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
                SciaRegs.SCILBAUD    =0x0030;  // 38400 bps
                     break;
        default:break;
       }

       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x0060;  // 19200 bps

       //SciaRegs.SCIHBAUD    =0x0000;   // LSPCLK = 15MHz. 
       //SciaRegs.SCILBAUD    =0x000E;  // 125K bps
       
       SciaRegs.SCICTL1.bit.RXENA = 0;
       SciaRegs.SCICTL1.bit.TXENA = 1;
       SciaRegs.SCICTL1.bit.SWRESET = 1;
       //SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset 
       
       EDIS;
}

void SCIAVarInit(void)
{
       unsigned int i = 0;
       
       SCIAIntRxCnt = 0;
       SCIAIntTxCnt = 0;
       SCIAIntTxLen = 0;
       SCIAIdleCnt = 0;
       SCIAStatus = 0;
       SCIAKey = 0;
       
       SCIATxTimeCnt = 0;
       
       for( i = 0; i< SCIARXMAX ; i++ ) 
       {
              SCIARxApp.SCIARxAppArray[i] = 0;
              SCIAIntRx[i] = 0;
       }
       
       
       for( i = 0; i< SCIATXMAX ; i++ )
       {
              SCIATxApp.SCIATxAppArray[i] = 0;
              SCIAIntTx[i] = i;//0;
       }

       for( i = 0; i< SCIAFILTERTIME ; i++)
       {
           ConToInvFilter[0][i] = 0;
           ConToInvFilter[1][i] = 0;
       }
       
       SCIAIntTx[0] = SCIAFrame;
}

void SCIA_Init(void)
{
  SCIAGPIOInit();
  SCIARxInit();
  SCIAVarInit();
}

以下是判断是否有接收数据:
to judge whether there is data

void SCIARxStatus0Prc(void)
{
    if( SciaRegs.SCIFFRX.bit.RXFFST != 0 )
       {  //有接收到数据,进入接收状态
              SCIAStatus = 1;
              SCIAFrameEnd = 0;
              SCIAIdleCnt = 0;

              while(SciaRegs.SCIFFRX.bit.RXFFST != 0 )
              {
                     if(SCIAIntRxCnt >= SCIARXMAX)
                     {   //防止接收异常,异常处理后下一帧正常
                            SCIAIntRxCnt = 0;
                            SCIAStatus = 0;
                            return;
                     }
                     else
                     {
                            SCIAIntRx[SCIAIntRxCnt] =  SciaRegs.SCIRXBUF.bit.RXDT;
                            SCIAIntRxCnt++;
                     }
              }
       }
       else 
       {
              SCIAIntRxCnt = 0;   
              SCIAFrameEnd = 0;
              SCIAIdleCnt++;
              if( SCIAIdleCnt >= SCIAIDLE ) 
              {
                     SCIAIdleCnt = 0;
                     SCIARxErrCnt++;  
                     if(SCIARxErrCnt >= 100) 
                     {
                            SCIARxErrCnt = 100;
                     }
              }
       }
}

below is the normal condition register status

for abnormal status, the SCIRXST is changed to 0x00B6 or 0x00B2.

Could you kindly review it and give some comments?

BR

Emma

  • Hi Emma,

    The first thing to note is the SCIRXST changing to 0x00B6 or 0x00B2. This shows there is a receiver error flag (RXERROR) which is set when any of flags 5-2 of SCIRXST are set. Error is causing because of Break detect (SCI receiver data line (SCIRXD) remains continuously low for at least ten bits), Framing error (an expected stop bit is not found) and parity error (parity mismatch).

    What is the baud rate that is being used? Is the parity check configured on transmit side?

    Check if the GPIO pull up configuration is working correctly on the board.

    It could be due to some external noise. Is the system isolated?

    To recover from receiver error you can use software reset when ever the program detects RXERROR. 

    SciaRegs.SCICTL1.bit.SWRESET = 0;

    SciaRegs.SCICTL1.bit.SWRESET = 1;

    Thanks,

    Yashwant 

  • Yashwant,

    Yashwant Temburu1 said:
    What is the baud rate that is being used? Is the parity check configured on transmit side?

    Yes, 19200

    Yashwant Temburu1 said:
    Check if the GPIO pull up configuration is working correctly on the board.

    Yes

    Yashwant Temburu1 said:
    It could be due to some external noise. Is the system isolated?

    it can also happened in the lab, so it is not the root. cause.

    and the odd thing is if they can not receive data in FIFO for 600 times, they re initiation the SCI using the same init function.

    then the issue is clear, so Customer wants to know the root cause.

    to judge whether there is data
    
    void SCIARxStatus0Prc(void)
    {
        if( SciaRegs.SCIFFRX.bit.RXFFST != 0 )
           {     //receive effective data
                  SCIAStatus = 1;
                  SCIAFrameEnd = 0;
                  SCIAIdleCnt = 0;
    
                  while(SciaRegs.SCIFFRX.bit.RXFFST != 0 )
                  {
                         if(SCIAIntRxCnt >= SCIARXMAX)
                         {   //防止接收异常,异常处理后下一帧正常
                                SCIAIntRxCnt = 0;
                                SCIAStatus = 0;
                                return;
                         }
                         else
                         {
                                SCIAIntRx[SCIAIntRxCnt] =  SciaRegs.SCIRXBUF.bit.RXDT;
                                SCIAIntRxCnt++;
                         }
                  }
           }
           else 
           {
                  SCIAIntRxCnt = 0;   
                  SCIAFrameEnd = 0;
                  SCIAIdleCnt++;
                  if( SCIAIdleCnt >= SCIAIDLE ) 
                  {
    		     SCIARxInit();
                         SCIAIdleCnt = 0;
                         SCIARxErrCnt++;  
                         if(SCIARxErrCnt >= 100) 
                         {
                                SCIARxErrCnt = 100;
                         }
                  }
           }
    }

    and the SCIAIDLE equals to 600.

    Thanks in advance!

    BR

    Emma

  • Emma,

                  Clearly, there has been an error. In other words, it is not that the reception has suddenly stopped without any error condition being flagged. Without identifying what caused the error condition, the issue cannot be debugged.

  • Hi Emma,

    Does the customer re-initialize the SCI just once, after which operation continues without errors? 

    Also curious to know if the same thing happens when you operate at a lower baud rate, say 9600?  

    Note that the occurrence of a break (BRKT) causes a receiver interrupt to be generated if the RX/BK INT ENA bit is a 1, but it does not cause the receiver buffer to be loaded. This could be why you don't see data for 600 times until you perform the initialization again clearing the BRKT bit.

    Instead of waiting for 'SCIAIdleCnt' to equal 600 I would encourage you to monitor the RXERROR bit in the SCIRXST register and if it is set check for the parity error bit (PE), framing error bit (FE), and SCI break-detect bit (BRKT) within the same register. This will help us narrow down what kind of error you are getting and at what time during the communication cycle.

    Best Regards,

    Marlyn

  • Hareesh,

    Actually, the host MCU will send the data before F28034 finish initiation.

    But at most tests, it will all right.

    does it will cause the SCI receive error?

    BR

    Emma

  • Hi Emma,

    This could be a possible concern. Would you please try adding a delay on the host side so that it does not transmit until the receiving device has had time to finish its initialization?

    Best Regards,

    Marlyn