#include "DSP2833x_Device.h"
#include "DSP2833x_Examples.h"
void sci_init(void);
interrupt void uartIsr(void);
interrupt void uart_send(void);
void delay(void);
unsigned char m;
void main(void)
{
InitSysCtrl();
DINT;
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl();
InitPieVectTable();
EnableInterrupts();
InitScicGpio();
sci_init();
EALLOW;
PieVectTable.SCIRXINTC = &uartIsr;
PieVectTable.SCITXINTC = &uart_send;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE=1;
PieCtrlRegs.PIEIER8.bit.INTx5=1;
PieCtrlRegs.PIEIER8.bit.INTx6=1;
IER|=M_INT8;
EINT;
ERTM;
while(1);
}
void sci_init(void)
{
EALLOW;
ScicRegs.SCICCR.all =0x0007;
ScicRegs.SCICTL1.all =0x0003;
// ScicRegs.SCICTL2.all =0x0003;
ScicRegs.SCICTL2.bit.TXINTENA=1;
ScicRegs.SCICTL2.bit.RXBKINTENA=1;
ScicRegs.SCIHBAUD =0x0001;
ScicRegs.SCILBAUD =0x0086;
ScicRegs.SCICTL1.bit.SWRESET=1;
EDIS;
}
void uart_send(void)
{
PieCtrlRegs.PIEACK.all=0x0080;
}
void uartIsr(void)
{
m=ScicRegs.SCIRXBUF.all;
ScicRegs.SCITXBUF=m;
PieCtrlRegs.PIEACK.all=0x0080;
}
注意这里修改了一个中断服务函数的地址,一开始我没有使用interrupt,结果就悲剧了,一定要使用这个哦,就是上面声明的时候要加上。然后就是清除应答ack。开启中断我总结了要开5个:1.外设中断(如串口要使用的话,开好自己的中断,一般在外设初始化中开启,从上面也可以看出。)2.PIE中对应的外设中断,见上面的INTx.5,3.PIE的总开关ENPIE,4.CPU级中断 IER,对应的PIE中某一组开关,如上面的IER|=M_INT8,5.总开关EINT
4.测试结果: