Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE
Tool/software:
Hello,
I am using the Launchpad F280049 board and I'm trying to understand how to use interrupts to implement SCI communication with the host computer. The example used and modified is the sci_ex2_interrupts.c located at (C:\ti\c2000\C2000Ware_5_01_00_00\driverlib\f28004x\examples\sci).
To get straight to the point, when I try to send a character array from the host computer, the SCIRX interrupt does it's job, receives the characters and sends them back. Even though the job of the ISR routine is finished, the RX interrupt is called again. But in this case, I'm not sending any characters to the RX so the readCharArray function just waits forever and thus ISR never returns.
SCIRX and SCITX ISR routines
__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++;
}
When I try to disable the RX interrupt inside the ISR and enable it inside the TX ISR, the RX ISR never gets stuck calling itself and receives characters and exits properly.
__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++;
}
My question is: why does disabling and enabling an interrupt in this manner work? What is making the program call the ISR again in the first case even though there are no characters in the SCIRXBUF register?
I hope I covered everything clearly but if not, happy to provide more detail.
Thank you.

