我用合众达的SCI测试程序进行SCI 测试时出现一个问题,就是我觉得程序应该是将从上位机发送过去的字符返回来,但我以运行程序,没有从上位机向dsp发送字符就可以从串口调试助手上看到DSP 发送过来一大堆字符。 而且即使我把程序停止掉 ,甚至dsp断电,上位机还是老是接收到字符。。不知道是什么原因,哪位大哥帮帮忙。。谢谢!!! 代码如下: #include "DSP28_Device.h" unsigned int Sci_VarRx[100]; unsigned int i,j; unsigned int Send_Flag;
void main(void) {
/*初始化系统*/ InitSysCtrl();
/*关中断*/ DINT; IER = 0x0000; IFR = 0x0000;
/*初始化PIE中断*/ InitPieCtrl();
/*初始化PIE中断矢量表*/ InitPieVectTable(); /*初始化SCIA寄存器*/ InitSci(); for(i = 0; i < 100; i++) { Sci_VarRx = 0; } i = 0; j = 0; 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; #endif EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM
for(; { if((SciaTx_Ready() == 1) && (Send_Flag == 1)) { SciaRegs.SCITXBUF = Sci_VarRx; Send_Flag = 0; i++; if(i == j) { i = 0; j = 0; } } #if !SCIA_INT if(SciaRx_Ready() == 1) { Sci_VarRx[j] = SciaRegs.SCIRXBUF.all; Send_Flag = 1; j++; if(j == 100) { j = 0; } } #endif }
}
//=========================================================================== // No more. //===========================================================================
void InitSci(void) { // Initialize SCI-A: *UART_MODE = 0x44; EALLOW; GpioMuxRegs.GPFMUX.all = 0x0030; EDIS; /* loopback 8 bit data */ SciaRegs.SCICCR.all = 0x07; SciaRegs.SCICTL1.all = 0x03; SciaRegs.SCICTL2.all = 0x03; SciaRegs.SCIHBAUD = 0x00; SciaRegs.SCILBAUD = 0xF3; SciaRegs.SCICTL1.all = 0x23; PieCtrl.PIEIER9.bit.INTx1 = 1; PieCtrl.PIEIER9.bit.INTx2 = 1; //tbd...
// Initialize SCI-B:
//tbd... }
/******************************************************************************** name: int SciaTx_Ready(void) input: none output: i 1: ready 0: busy *********************************************************************************/
int SciaTx_Ready(void) { unsigned int i; if(SciaRegs.SCICTL2.bit.TXRDY == 1) { i = 1; } else { i = 0; } return(i); }
/******************************************************************************** name: int SciaRx_Ready(void) input: none output: i 1: new data 0: none *********************************************************************************/
int SciaRx_Ready(void) { unsigned int i; if(SciaRegs.SCIRXST.bit.RXRDY == 1) { i = 1; } else { i = 0; } return(i); }
//=========================================================================== // No more.
|