void main(void)
{
InitSysCtrl();
InitSciGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SCIRXINTA = &sciaRxFifoIsr;
PieVectTable.SCITXINTA = &sciaTxFifoIsr;
PieVectTable.SCIRXINTB = &scibRxFifoIsr;
PieVectTable.SCITXINTB = &scibTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers
scia_fifo_init(); // Init SCI-A
scib_fifo_init(); // Init SCI-B
scib_msg(m);
scia_msg(m);//先发送数据判断串口是否工作正常
// Enable interrupts required for this example
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, int1
PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2
PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
IER = 0x100; // Enable CPU INT
EINT;
while(1)
{
}
}
void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
interrupt void scibTxFifoIsr(void);
interrupt void scibRxFifoIsr(void);
void scib_fifo_init(void);
void error(void);
char m[12]="12345678abcd";
void main(void)
{
InitSysCtrl();
InitSciGpio();
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.SCIRXINTB = &scibRxFifoIsr;
PieVectTable.SCITXINTB = &scibTxFifoIsr;
EDIS; // This is needed to disable write to EALLOW protected registers
scib_fifo_init(); // Init SCI-B
PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block
PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3
PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4
IER = 0x100; // Enable CPU INT
EINT;
for(;;);
}
void error(void)
{
asm(" ESTOP0"); // Test failed!! Stop!
for (;;);
}
//===========================================================================
// No more.
//===========================================================================
之前上网查资料的时候,看到有人说在不使用FIFO的情况下需要先发送一个数据才能进入中断。可以使用 ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;来控制发送FIFO中断的进入。当想发送数据的时候就将中断标志清零,进入中断程序之后再进行数据加载发送。还可以添加标志位来确定在中断程序中发送那些数据。