Other Parts Discussed in Thread: C2000WARE
Hi,
I am trying to develop a communication protocol using SCI in TMS320F28388. Maximum 512 bytes of data can come through this SCI and the controller should be able to store the data using RX interrupt method.
Below is the code I am using for SCI configuration.
GPIO_setPinConfig(GPIO_19_SCIB_RX); GPIO_setPinConfig(GPIO_18_SCIB_TX); // // Interrupts that are used in this example are re-mapped to // ISR functions found within this file. // Interrupt_register(INT_SCIB_RX, sciaRXFIFOISR); SCI_performSoftwareReset(SCIB_BASE); // // Configure SCIA for echoback. // SCI_setConfig(SCIB_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 | SCI_CONFIG_STOP_ONE | SCI_CONFIG_PAR_NONE)); SCI_resetChannels(SCIB_BASE); SCI_enableModule(SCIB_BASE); SCI_performSoftwareReset(SCIB_BASE); SCI_enableFIFO(SCIB_BASE); // // RX FIFO Interrupts Enabled // SCI_enableInterrupt(SCIB_BASE, SCI_INT_RXFF); SCI_disableInterrupt(SCIB_BASE, SCI_INT_RXERR); // // The transmit FIFO generates an interrupt when FIFO status // bits are less than or equal to 2 out of 16 words // The receive FIFO generates an interrupt when FIFO status // bits are greater than equal to 2 out of 16 words // SCI_setFIFOInterruptLevel(SCIB_BASE, SCI_FIFO_TX2, SCI_FIFO_RX2); SCI_performSoftwareReset(SCIB_BASE); SCI_resetRxFIFO(SCIB_BASE); Interrupt_enable(INT_SCIB_RX); Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
Below is the code in the ISR to read the data.
uint16_t flags;
uint16_t chr;
uint16_t words;
if (ReceiveBufferLen != 0) // if buffer is busy
return;
do // until TerminationChar received or rcv buf is empty
{
flags = SCI_getRxStatus(SCIB_BASE);
if (NumCharsReceived >= RX_BUFF_SIZE)
{
ErrorCode = SerialRxBuffTooSmall; // ReceiveBuffer too small
ReceiveBufferLen = RX_BUFF_SIZE; // inform the user a partial packet is available
break;
}
//
if (SCI_getRxFIFOStatus(SCIB_BASE))
{
chr = SCI_readCharBlockingFIFO(SCIB_BASE);
//
// // If no data is available, break
//
((uint16_t*) &ReceiveBuffer)[NumCharsReceived++] = chr;
if (((((uint16_t) (ReceiveBuffer[1]) << 8) & 0xFF00u)
| ((uint16_t) (ReceiveBuffer[0] & 0x00FFu)))
== NumCharsReceived)
{
ReceiveBufferLen = NumCharsReceived; // inform the user a packet is available
//break;
}
} while (!SCI_isDataAvailableNonFIFO(SCIB_BASE));
SCI_clearOverflowStatus(SCIB_BASE);
SCI_clearInterruptStatus(SCIB_BASE, SCI_INT_RXFF);
//
// Issue PIE ack
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
Using this code I am able to read only 2 bytes of data.
Can any one help me to get some idea on this to read multiple bytes of data through SCI Rx using interrupt method.
Thanks in advance
Regards
Dipin