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);
}