麻烦您们帮忙看下程序,怎么不管用:
#include "DSP28_Device.h"
unsigned int Sci_VarRx[100];
unsigned int i,j;
unsigned int Send_Flag;
void delay(unsigned int t);
void main(void)
{
/*初始化系统*/
InitSysCtrl();
/*关中断*/
DINT;
IER = 0x0000;
IFR = 0x0000;
/*初始化PIE中断*/
InitPieCtrl();
/*初始化GPIO*/
InitGpio();
/*初始化PIE中断矢量表*/
InitPieVectTable();
/*初始化SCIB寄存器*/
InitSci();
for(i = 0; i < 100; i++)
{
Sci_VarRx[i] = i;
}
i = 0;
j = 0;
Send_Flag = 0;
#if SCIB_INT ///查看DSP28_Device.h,可用中断接收,但目前我们采用查询接收
//设置中断服务程序入口地址
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TXBINT = &SCITXINTB_ISR;
PieVectTable.RXBINT = &SCIRXINTB_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
//开中断
IER |= M_INT9;
#endif
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
for(;;)
{
if((ScibTx_Ready() == 1) && (Send_Flag == 1))
{
delay(10);
ScibRegs.SCITXBUF = Sci_VarRx[i];
Send_Flag = 0;
i++;
if(i == j)
{
i = 0;
j = 0;
}
while(ScibTx_Ready() != 1); //等待发送结束
delay(1000);
}
if(ScibRx_Ready() == 1)
{
Sci_VarRx[j] = ScibRegs.SCIRXBUF.all;
Send_Flag = 1;
j++;
if(j == 100)
{
j = 0;
}
}
}
}
void delay(unsigned int t)
{
unsigned int a,b;
for(a=0;a<t;a++)
for(b=0;b<100;b++);
} |