想用CPU查询的方式实现PC上位机发给DSP一个什么字节,DSP就回复PC一个什么字节。DSP却接收不到数据,RXRDY标志位一直为0,RXBUF也为0,只是RXWAKE标志位一直为1,不知道RXWAKE在单机通信中有何用?以下是代码,各位高手多多指教啊!
int main(void)
{
unsigned char tx_data = 0;
unsigned char rx_data = 0;
#ifdef FLASH
MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
InitFlash();
#endif
InitSysCtrl();
InitSciaGpio();
SciaRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
SciaRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
SciaRegs.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD =0x0000; // 9600 baud @LSPCLK = 15MHz (60 MHz SYSCLK).
SciaRegs.SCILBAUD =0x00C2;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
SciaRegs.SCIFFTX.bit.SCIRST = 1;
while(1)
{
while(SciaRegs.SCIRXST.bit.RXRDY != 1);
rx_data = SciaRegs.SCIRXBUF.bit.RXDT;
tx_data = rx_data;
Delay(0xffff);
Delay(0xffff);
Delay(0xffff);
Delay(0xffff);
while (SciaRegs.SCICTL2.bit.TXRDY == 0);
SciaRegs.SCITXBUF = tx_data;
Delay(0xffff);
Delay(0xffff);
Delay(0xffff);
Delay(0xffff);
}
}
void InitSciaGpio()
{
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pull-up for GPIO28 (SCIRXDA)
GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pull-up for GPIO29 (SCITXDA)
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input GPIO28 (SCIRXDA)
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // Configure GPIO28 for SCIRXDA operation
GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // Configure GPIO29 for SCITXDA operation
EDIS;
}
|