我想用28069的SCI向计算机发送数据,通过定时器一秒钟发送一次数据,用的SCIA,GPIO28和GPIO29。经过测试硬件没有问题
可能是SCI配置有问题,程序运行正常,定时器中断能正常进入,但是串口助手没有显示出数据。
void scia_init()
{
// Note: Clocks were turned on to the SCIA peripheral
// in the InitSysCtrl() function
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.SCICTL2.bit.TXINTENA =1;
SciaRegs.SCICTL2.bit.RXBKINTENA =1;
SciaRegs.SCIHBAUD =0x0001;
SciaRegs.SCILBAUD =0x0024; //9600波特率
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
__interrupt void cpu_timer0_isr(void)
{
while(SciaRegs.SCICTL2.bit.TXEMPTY == 0) { }
scia_xmit(SendChar);
SendChar++;
// Limit the character to 8-bits
SendChar &= 0x00FF;
LoopCount++;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
void scia_xmit(int a)
{
if(SciaRegs.SCICTL2.bit.TXRDY==1)
SciaRegs.SCITXBUF=a;
} |