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.

TMS320F280025C: the timining issue between SCI_writeCharArray and SCI_readCharArray

Part Number: TMS320F280025C
Other Parts Discussed in Thread: C2000WARE

Tool/software:

Hi,

When I am using SCI_readCharArray(SCIA_BASE, rx_buffer, 17) inside __interrupt void INT_mySCI0_RX_ISR(void)) and SCI_writeCharArray(SCIA_BASE, tx_buffer, 17); inside the for(;;) loop as shown below.

1. The SCI_writeCharArray(SCIA_BASE, tx_buffer, 17) working fine but SCI_readCharArray(SCIA_BASE, rx_buffer, 17) receive wrong  data.

2. When  make the statement SCI_writeCharArray(SCIA_BASE, tx_buffer, 17) then SCI_readCharArray working fine.

Either SCI_readCharArray or SCI_writeCharArray working at a time. I am encountering an issue where the SCI_readCharArray and SCI_writeCharArray functions are interfering with each other.

The detail code is below.

__interrupt void INT_mySCI0_RX_ISR(void)
{
SCI_clearOverflowStatus(SCIA_BASE);

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;
SCI_performSoftwareReset(SCIA_BASE);
DEVICE_DELAY_US(10);
}

// Clear RX FIFO status


// Receive 17 Byte in Uart ISR
if (rxStatus > 0)
{
//DEVICE_DELAY_US(5000); // DEVICE_DELAY_US(5000);
// SCI_clearOverflowStatus(SCIA_BASE);
SCI_readCharArray(SCIA_BASE, rx_buffer, 17);

// If the First Byte is 0x65, then move data in an actual variable from the Receive Buffer
if (rx_buffer[0] == 0x65)
{
voltage = (((rx_buffer[7] - 0x30) * 100) + ((rx_buffer[8] - 0x30) * 10) + (rx_buffer[9] - 0x30));
frequency = (((rx_buffer[12] - 0x30) * 100) + ((rx_buffer[13] - 0x30) * 10) + (rx_buffer[14] - 0x30));
duty = (((rx_buffer[15] - 0x30) * 10) + (rx_buffer[16] - 0x30));
}

SCI_clearInterruptStatus(SCIA_BASE, SCI_INT_RXFF);
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}

}

The SCI_writeCharArray(SCIA_BASE, tx_buffer, 17); in the for loop

{
// measured_voltage=voltage;
measured_voltage = 1200*adcA7_display_pu_avg;

tx_buffer[0] = 0x76;//(V)
tx_buffer[1] = 0x6f;//(o)
tx_buffer[2] = 0x6c;//(l)
tx_buffer[3] = 0x74;//(t)
tx_buffer[4] = 0x2E;//(.)
tx_buffer[5] = 0x74;//(t)
tx_buffer[6] = 0x78;//(x)
tx_buffer[7] = 0x74;//(t)
tx_buffer[8] = 0x3D;//(=)
tx_buffer[9] = 0x22;//(")
tx_buffer[10] = ((measured_voltage/100)+0x30);//(Voltage)
tx_buffer[11] = (((measured_voltage%100)/10)+0x30);//(Voltage)
tx_buffer[12] = ((measured_voltage%10)+0x30);//(Voltage)
tx_buffer[13] = 0x22;//(")
tx_buffer[14] = 0xFF;
tx_buffer[15] = 0xFF;
tx_buffer[16] = 0xFF;
// SCI_clearOverflowStatus(SCIA_BASE);
SCI_writeCharArray(SCIA_BASE, tx_buffer, 17);

}

  • Hi Ram,

    There is a known issue in the SCI_writeCharArray() function when FIFO is enabled.

    Specifically, on line 120, the comparison should be with SCI_FIFO_TX16 instead of SCI_FIFO_TX15. Could you update the driver with this change and rebuild to see if it solves your issue.

    This should be rectified in the next release of C2000Ware.

    Thanks,

    Arnav  

  • Hi Arnav  

    Thanks, for solution, I have done the correction SCI_FIFO_TX16 instead of SCI_FIFO_TX15.

    Problem is resolved by inserting the delay befor  SCI_readCharArray(SCIA_BASE, rx_buffer, 17); this delay is required in one time. The jk variable is used only one time.

       if (rxStatus > 0)

        {

           if (jk==0)

           {

           DEVICE_DELAY_US(6000);  //   DEVICE_DELAY_US(5000);

           jk=1;

           }

           SCI_readCharArray(SCIA_BASE, rx_buffer, 17);

    Why this happen I do not know

    Regards

  • Hi Ram,

    The SCI FIFO can be configured for a maximum of 16 words. In your RX ISR, you are reading 17 words, which may not work as expected, since the FIFO can only guarantee availability of up to 16 words at a time. You could try adjusting these parameters and see if it makes a difference.

    Thanks,

    Arnav