Thread 中讨论的其他器件:C2000WARE
工具与软件:
您好!
我正在使用 Launchpad F280049电路板、我正在尝试了解如何使用中断来实现 SCI 与主机的通信。 使用和修改的示例是 位于(C:\ti\c2000\C2000Ware_5_01_00_00\driverlib\f28004x\examples\sci)的 sci_ex2_interrupts.c。
为了直接到达这个点、当我尝试从主机发送一个字符数组时、SCIRX 中断会执行它的工作、接收这些字符并将它们发回。 即使 ISR 例程的作业已完成、也会再次调用 RX 中断。 但在本例中、我不会向 RX 发送任何字符、因此 readCharArray 函数只会一直等待、因此 ISR 绝不会返回。
SCIRX 和 SCITX ISR 例程
__interrupt void
sciaTxISR(void)
{
//
// Disable the TXRDY interrupt.
//
SCI_disableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
msg = "\r\nEnter a character: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 22);
//
// Ackowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
__interrupt void
sciaRxISR(void)
{
//
// Enable the TXRDY interrupt again.
//
SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
//
// Read a character from the RXBUF.
// MSG_LENGTH = 10 characters
SCI_readCharArray(SCIA_BASE, msgreceive, MSG_LENGTH); // HERE IS THE PROBLEM
//
// Echo back the character.
//
msg = "You sent: ";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msgreceive, MSG_LENGTH);
//recievemsg = (uint16_t)(HWREGH(SCIA_BASE + SCI_O_RXBUF) & SCI_RXBUF_SAR_M);
//
// Acknowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
counter++;
}
当我尝试在 ISR 内部禁用 RX 中断并 在 TX ISR 内部启用该中断时、RX ISR 绝不会卡住调用、而去接收字符并正确退出。
__interrupt void
sciaTxISR(void)
{
//
// Disable the TXRDY interrupt.
//
SCI_disableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
SCI_enableInterrupt(SCIA_BASE, SCI_INT_RXRDY_BRKDT); //ENABLE RX INTERRUPT
msg = "\r\nEnter a character: \0";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 22);
//
// Ackowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
}
//
// sciaRxISR - Read the character from the RXBUF and echo it back.
//
__interrupt void
sciaRxISR(void)
{
//
// Enable the TXRDY interrupt again.
//
SCI_disableInterrupt(SCIA_BASE, SCI_INT_RXRDY_BRKDT); // DISABLE RX INTERRUPT
SCI_enableInterrupt(SCIA_BASE, SCI_INT_TXRDY);
//
// Read a character from the RXBUF.
//
SCI_readCharArray(SCIA_BASE, msgreceive, MSG_LENGTH);
//
// Echo back the character.
//
msg = "You sent: ";
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msg, 13);
SCI_writeCharArray(SCIA_BASE, (uint16_t*)msgreceive, MSG_LENGTH);
//recievemsg = (uint16_t)(HWREGH(SCIA_BASE + SCI_O_RXBUF) & SCI_RXBUF_SAR_M);
//
// Acknowledge the PIE interrupt.
//
Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP9);
counter++;
}
我的问题是:为什么以这种方式禁用和启用中断有效? 即使 SCIRXBUF 寄存器中没有字符、程序如何在第一种情况下再次调用 ISR?
我希望我能清楚地介绍所有内容、但如果没有、我很乐意提供更多详细信息。
谢谢你。

