This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377S 请教关于串口中断问题

// Included Files

//
#include "driverlib.h"
#include "device.h"

//
// Globals
//

//
// Send data for SCI-A
//
uint16_t sDataA[2];

//
// Received data for SCI-A
//
uint16_t rDataA[2];

//
// Used for checking the received data
//
uint16_t rDataPointA;


uint16_t a=0,b=0;

//
// Function Prototypes
//
__interrupt void scicTXFIFOISR(void);
__interrupt void scicRXFIFOISR(void);
void initSCIAFIFO(void);
void error(void);

//
// Main
//
void main(void)
{


//
// Initialize device clock and peripherals
//
Device_init();

//
// Setup GPIO by disabling pin locks and enabling pullups
//
Device_initGPIO();

//
// GPIO28 is the SCI Rx pin.
//
GPIO_setMasterCore(90, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_90_SCIRXDC);
GPIO_setDirectionMode(90, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(90, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(90, GPIO_QUAL_ASYNC);

//
// GPIO29 is the SCI Tx pin.
//
GPIO_setMasterCore(89, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_89_SCITXDC);
GPIO_setDirectionMode(89, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(89, GPIO_PIN_TYPE_STD);
GPIO_setQualificationMode(89, GPIO_QUAL_ASYNC);

//
// Initialize PIE and clear PIE registers. Disables CPU interrupts.
//
Interrupt_initModule();

//
// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
//
Interrupt_initVectorTable();

//
// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
//
Interrupt_register(INT_SCIC_RX, scicRXFIFOISR);
Interrupt_register(INT_SCIC_TX, scicTXFIFOISR);

//
// Initialize the Device Peripherals:
//
initSCIAFIFO();

sDataA[0] = 0x0055;

Interrupt_enable(INT_SCIC_RX);
Interrupt_enable(INT_SCIC_TX);

Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8);
//
// Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
//
EINT;
ERTM;

//
// IDLE loop. Just sit and loop forever (optional):
//
for(;;);
}

//
// error - Function to halt debugger on error
//
void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}

//
// scicTXFIFOISR - SCIA Transmit FIFO ISR
//
__interrupt void scicTXFIFOISR(void)
{


SCI_clearInterruptStatus(SCIC_BASE, SCI_INT_TXFF);

Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8);

b++;
}

//
// scicRXFIFOISR - SCIA Receive FIFO ISR
//
__interrupt void scicRXFIFOISR(void)
{


SCI_readCharArray(SCIC_BASE, rDataA, 1);


SCI_clearOverflowStatus(SCIC_BASE);

SCI_clearInterruptStatus(SCIC_BASE, SCI_INT_RXFF);

Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP8);

a++;
}

//
// initSCIAFIFO - Configure SCIA FIFO
//
void initSCIAFIFO()
{
//
// 8 char bits, 1 stop bit, no parity. Baud rate is 9600.
//
SCI_setConfig(SCIC_BASE, DEVICE_LSPCLK_FREQ, 9600, (SCI_CONFIG_WLEN_8 |
SCI_CONFIG_STOP_ONE |
SCI_CONFIG_PAR_NONE));
SCI_enableModule(SCIC_BASE);
//SCI_enableLoopback(SCIC_BASE);
SCI_resetChannels(SCIC_BASE);
SCI_enableFIFO(SCIC_BASE);

//
// RX and TX FIFO Interrupts Enabled
//
SCI_enableInterrupt(SCIC_BASE, (SCI_INT_TXFF | SCI_INT_RXFF));
SCI_disableInterrupt(SCIC_BASE, SCI_INT_RXERR);

SCI_setFIFOInterruptLevel(SCIC_BASE, SCI_FIFO_TX1, SCI_FIFO_RX1);
SCI_performSoftwareReset(SCIC_BASE);

SCI_resetTxFIFO(SCIC_BASE);
SCI_resetRxFIFO(SCIC_BASE);

#ifdef AUTOBAUD
//
// Perform an autobaud lock.
// SCI expects an 'a' or 'A' to lock the baud rate.
//
SCI_lockAutobaud(SCIC_BASE);
#endif
}

//
// End of file
//

配置串口SCIC,89,90脚,FIFO,1级深度触发中断,之后不做任何处理。

在中断处理函数中加入观察变量ab能够发现,仿真的时候不断进入发送中断,有时又不断进入接收中断。

ab的数值一直在非常大的范围变化。

IDE CCS7  launchpad