功能:向PC通过SCI串口发送一个方波的坐标点数据
问题:发送中断服务程序中,+长时间延迟,PC才能正常收到数据,延迟越短,接受到数据越少,不加延时4000个字节的数据,只能收到3,4个,冰天雪地跪求大神解答啊!!!!!!!
程序如下:
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
void Scib_init();
interrupt void Scib_RXISR();
interrupt void Scib_TXISR();
int m,n,count=0;
char rdata[16];
struct Point
{
int x;
int y;
};
struct Point sdata_rect[2000];
void main(void)
{
int i=0,flag=5;
InitSysCtrl();
InitScibGpio();
DINT;
InitPieCtrl();
IFR=0x0000;
IER=0x0000;
InitPieVectTable();
Scib_init();
EALLOW;
PieVectTable.SCIRXINTB=&Scib_RXISR;
PieVectTable.SCITXINTB=&Scib_TXISR;
EDIS;
PieCtrlRegs.PIECTRL.bit.ENPIE=1;
PieCtrlRegs.PIEIER9.bit.INTx3=1;
PieCtrlRegs.PIEIER9.bit.INTx4=1;
IER|=M_INT9;
//各种复位状态的清除
ScibRegs.SCICTL1.bit.SWRESET=1;
ScibRegs.SCIFFTX.bit.SCIRST=1;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1;
//产生模拟方波数据
for(i=0;i<2000;i++)
{
sdata_rect[i].x=i;
if(i%200==0)
{
flag=-flag;
sdata_rect[i].y=flag+10;
}
else
{
sdata_rect[i].y=flag+10;
}
}
EINT;
ERTM;
for(;;)
{
}
}
void Scib_init()
{
ScibRegs.SCIFFTX.bit.SCIRST=0;
//8位数据,1位停止,无校验
ScibRegs.SCICCR.bit.ADDRIDLE_MODE=0;
ScibRegs.SCICCR.bit.PARITYENA=0;
ScibRegs.SCICCR.bit.STOPBITS=0;
ScibRegs.SCICCR.bit.SCICHAR=7;
//2400波特率
// ScibRegs.SCIHBAUD=0x0007;
// ScibRegs.SCILBAUD=0x00A0;
//9600波特率
ScibRegs.SCIHBAUD=0x0001;
ScibRegs.SCILBAUD=0x00E7;
//发送16级FIFO 接收1级
ScibRegs.SCIFFTX.bit.TXFFIL=16;
ScibRegs.SCIFFRX.bit.RXFFIL=1;
//引脚传输使能
ScibRegs.SCICTL1.bit.RXENA=1;
ScibRegs.SCICTL1.bit.TXENA=1;
//中断使能
ScibRegs.SCIFFRX.bit.RXFFIENA=1;
ScibRegs.SCIFFTX.bit.TXFFIENA=1;
//使能FIFO
ScibRegs.SCIFFTX.bit.SCIFFENA=1;
}
interrupt void Scib_RXISR()
{
unsigned int temp,i;
DINT;
temp=ScibRegs.SCIFFRX.bit.RXFFST;
for(i=0;i<temp;i++)
{
rdata[i]=ScibRegs.SCIRXBUF.bit.RXDT;
}
ScibRegs.SCIFFRX.bit.RXFIFORESET=0;
ScibRegs.SCIFFRX.bit.RXFIFORESET=1;
ScibRegs.SCIFFRX.bit.RXFFOVRCLR=1;
ScibRegs.SCIFFRX.bit.RXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
EINT;
}
interrupt void Scib_TXISR()
{
char i=0;
int j,k;
DINT;
if(count>=3999)
{
PieCtrlRegs.PIEACK.all|=0x100;
return;
}
for(i=0;i<16;i++)
{
//发送一个方波数据,包括x,y点
if(count<2000)
ScibRegs.SCITXBUF=sdata_rect[count+i].x;
else
ScibRegs.SCITXBUF=sdata_rect[count-2000+i].y;
}
//这里!
for(j=0;j<1000;j++)
for(k=0;k<200;k++);
count?(count+=16):(count+=15);
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=0; //指针清0
ScibRegs.SCIFFTX.bit.TXFIFOXRESET=1; //退出复位状态
ScibRegs.SCIFFTX.bit.TXFFINTCLR=1;
PieCtrlRegs.PIEACK.all|=0x100;
EINT;
}