我用28035的标准的SCI串口进行首发数据,为什么只能接收一个字节的数据呢,比如是发送1234接收的只是最后一个4444,我用了数组将其存储了。请高手帮忙看看,程序如下
#include "DSP2803x_Device.h"
#include "DSP2803x_Examples.h"
void GPIO_Init();
void SCIA_Init();
void delay_loop();
int SCIRx[100],Send_Flag,i,j;
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
GpioDataRegs.GPADAT.bit.GPIO29=1;
GpioDataRegs.GPADAT.bit.GPIO9=1;
for(i=0;i<100;i++)
{
SCIRx[i]=0;
}
i=0;
j=0;
Send_Flag=0;
PieCtrlRegs.PIEIER9.bit.INTx1=1;
// PieCtrlRegs.PIEIER9.bit.INTx2=1;
IER|=M_INT9;
EINT;//开全局中断
ERTM;//开全局实时中断
GPIO_Init();
SCIA_Init();
while(1)
{
if(Send_Flag==1)
{
GpioDataRegs.GPADAT.bit.GPIO6=1;//禁止接收
SciaRegs.SCICTL1.bit.RXENA=0;//禁止接收
GpioDataRegs.GPADAT.bit.GPIO9=0;
delay_loop();
GpioDataRegs.GPADAT.bit.GPIO9=1;//发送数据指示灯
SciaRegs.SCITXBUF=SCIRx[j];
delay_loop();
j++;
if(j==8)
{
j=0;
Send_Flag=0;
GpioDataRegs.GPADAT.bit.GPIO6=0;//使能接收
SciaRegs.SCICTL1.bit.RXENA=1;
}
}
}
}
void GPIO_Init()
{
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO7=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO7=2;
GpioCtrlRegs.GPAQSEL1.bit.GPIO7=3;
GpioCtrlRegs.GPAPUD.bit.GPIO12=0;
GpioCtrlRegs.GPAMUX1.bit.GPIO12=2;
GpioCtrlRegs.GPAQSEL1.bit.GPIO12=3;
GpioCtrlRegs.GPAMUX1.bit.GPIO6=0;
GpioCtrlRegs.GPADIR.bit.GPIO6=1;
GpioCtrlRegs.GPAMUX1.bit.GPIO9=0;
GpioCtrlRegs.GPADIR.bit.GPIO9=1;
GpioCtrlRegs.GPAMUX2.bit.GPIO29=0;
GpioCtrlRegs.GPADIR.bit.GPIO29=1;
EDIS;
}
void SCIA_Init()
{
SciaRegs.SCICCR.bit.STOPBITS=0;
SciaRegs.SCICCR.bit.PARITYENA=0;
SciaRegs.SCICCR.bit.LOOPBKENA=0;
SciaRegs.SCICCR.bit.ADDRIDLE_MODE=0;
SciaRegs.SCICCR.bit.SCICHAR=7;
SciaRegs.SCICTL1.bit.RXENA=1;
SciaRegs.SCICTL1.bit.TXENA=1;
SciaRegs.SCIHBAUD=0;
SciaRegs.SCILBAUD=0xc2;
SciaRegs.SCICTL2.bit.RXBKINTENA=1;//使能接收中断
//SciaRegs.SCICTL2.bit.TXINTENA=1;//使能发送中断
SciaRegs.SCICTL1.bit.SWRESET=1;
}
interrupt void SCIRXINTA_ISR(void) // SCI-A
{
GpioDataRegs.GPADAT.bit.GPIO6=0;//使能接收
GpioDataRegs.GPADAT.bit.GPIO29=0;
delay_loop();
GpioDataRegs.GPADAT.bit.GPIO29=1;//接收数据指示灯
SCIRx[i]=SciaRegs.SCIRXBUF.all;
i++;
if(i==8)
{
Send_Flag=1;
i=0;
}
PieCtrlRegs.PIEACK.all=0x0100;
EINT;//开全局中断
}
/*interrupt void SCITXINTA_ISR(void) // SCI-A
{
GpioDataRegs.GPADAT.bit.GPIO6=1;
//SciaRegs.SCICTL2.bit.RXBKINTENA=0;
if(Send_Flag==1)
{
SciaRegs.SCITXBUF=SCIRx[j];
GpioDataRegs.GPADAT.bit.GPIO9=0;
delay_loop();
GpioDataRegs.GPADAT.bit.GPIO9=1;
j++;
if(j==8)
{
j=1;
Send_Flag=0;
}
}
PieCtrlRegs.PIEACK.all=0x0100;
EINT;
GpioDataRegs.GPADAT.bit.GPIO6=0;
//SciaRegs.SCICTL2.bit.RXBKINTENA=1;
}*/
void delay_loop()
{
short i,j;
for (i = 0; i < 1000; i++)
for(j=0;j<100;j++);
}
|