大家好,我结合TI的DSP28023例程,写了一个串口通信,查询方式的,可惜用串口助手发送数据时,之前好好的,现在收不到了,我把程序放出来,大家帮我看看,是不是哪里错了,没错的话估计是板子的事情
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
void scia_echoback_init(void);
void scia_xmit(int a);
// Global counts used in this example
Uint16 ReceivedChar;
void main(void)
{
InitSysCtrl();
InitSciaGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
// User specific code:
ReceivedChar = 0;
scia_echoback_init(); // Initialize SCI for echoback
scia_xmit();
for(;;)
{
while(SciaRegs.SCIRXST.bit.RXRDY==1){}
ReceivedChar = SciaRegs.SCIRXBUF.all;
scia_xmit(ReceivedChar);
}
}
void scia_echoback_init()
{
SciaRegs.SCIHBAUD =0x0000; // 9600 baud @LSPCLK = 12.5 MHz (50 MHz SYSCLK)
SciaRegs.SCILBAUD =0x00A1;
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.all =0x0003;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
// Transmit a character from the SCI
void scia_xmit(int a)
{
while(SciaRegs.SCICTL2.bit.TXRDY == 1){}
SciaRegs.SCITXBUF=a;
} |