也是书上的例子,自己学习过程中发现:2812无法进入SCI串口发送中断子程序,但是能正常进入接受中断子程序,求大神解释!程序如下:
void InitSci(void)
{
// Initialize SCI-A:
/* loopback 8 bit data */
SciaRegs.SCICCR.all = 0x07; // 1 bit stop, disable parity, idle mode, 8 bits data
SciaRegs.SCICTL1.all = 0x03; // enable TX RX
//SciaRegs.SCICTL2.all = 0x02; //
SciaRegs.SCICTL2.bit.RXBKINTENA=1;
SciaRegs.SCICTL2.bit.TXINTENA=0;//0和1试过
SciaRegs.SCIHBAUD = 0x00;
SciaRegs.SCILBAUD = 0xF3;
PieCtrl.PIEIER9.bit.INTx1 = 1;
PieCtrl.PIEIER9.bit.INTx2 = 1;
SciaRegs.SCICTL1.bit.SWRESET=1;
}
interrupt void SCIRXINTA_ISR(void) // SCI-A
{
Sci_VarRx = SciaRegs.SCIRXBUF.all;
i++;
if(i == 6)
{
//SciaRegs.SCITXBUF= Sci_VarRx[0];
Send_Flag = 1;
i = 0;
}
PieCtrl.PIEACK.bit.ACK9 = 1;
EINT;
}
interrupt void SCITXINTA_ISR(void) // SCI-A
{
if((Send_Flag == 1)&&(SciaRegs.SCICTL2.bit.TXRDY==1))
{
SciaRegs.SCITXBUF= Angle[0][j];
j++;
if(j>=6)Send_Flag = 0;
}
PieCtrl.PIEACK.bit.ACK9 = 1;
EINT;
}
#include "DSP28_Device.h"
unsigned int Sci_VarRx[6];
int Angle[10][6];
unsigned int i=0,j=0,k=0;
unsigned int Send_Flag=0;
//#define SCIA_INT 1
void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
/*初始化PIE中断*/
InitPieCtrl();
/*初始化PIE中断矢量表*/
InitPieVectTable();
/*初始化SCIA寄存器*/
InitSci();
for(i = 0; i < 6; i++)
{
Sci_VarRx = 0;
}
for(i = 0; i < 10; i++)
{
for(j = 0; j < 6; j++)
{
Angle[j]=k;
k++;
}
}
// i = 0;
///j = 1;
// Send_Flag = 0;
// #if SCIA_INT
/*设置中断服务程序入口地址*/
///EALLOW; // This is needed to write to EALLOW protected registers
//PieVectTable.TXAINT = &SCITXINTA_ISR;
//PieVectTable.RXAINT = &SCIRXINTA_ISR;
//EDIS; // This is needed to disable write to EALLOW protected registers
IER |= M_INT9;/*开中断*/
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
i=0;
j=0;
for(;;)
{
// for(k= 0; k< 50000; k++){}
//SciaRegs.SCIRXST.bit.RXRDY
}
} |