主题中讨论的其他器件:C2000WARE
您好!
我正在尝试使用 TMS320F28388中的 SCI 开发通信协议。 最大512字节的数据可以通过这个 SCI、并且控制器应该能够使用 RX 中断方法来存储数据。
下面 是我用于 SCI 配置的代码。
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);
下面是 ISR 中用于读取数据的代码。
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);
使用此代码、我只能读取2个字节的数据。
能不能有人帮助我了解这一点、以便使用中断方法通过 SCI Rx 读取多个字节的数据。
提前感谢
此致
双引脚