f28035请教

2019-07-31 15:21发布

以下是我程序中的SCI相关代码,我用中断方式接收,查询方式发送,但是不知为什么我用串口调试助手发送字符后不能接收到CPU发送回来的数据?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
2条回答
heibaiyinjiag
2019-07-31 19:48
void sInitSCI(void)
{
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pullup on GPIO28
GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // asynch input
GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // GPIO28 = SCIRXDA
GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pullup on GPIO29
GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // GPIO29 = SCITXDA
// GpioCtrlRegs.GPAQSEL2.bit.GPIO29 = 3; // asynch input
EDIS;

// One stop bit, no parity, 8-bit character length
SciaRegs.SCICCR.all=0x07;
// Enable transmit and receive, Relinquish SCI from Reset
SciaRegs.SCICTL1.all =0x03;
//bard= 115200
SciaRegs.SCIHBAUD=0x00;
SciaRegs.SCILBAUD=0x07;
// Enable Receive interrupt and transmit interrupt
SciaRegs.SCICTL2.bit.TXINTENA = 1;
SciaRegs.SCICTL2.bit.RXBKINTENA = 1;
// SciaRegs.SCICTL1.bit.SWRESET = 1;
SciaRegs.SCICTL1.all = 0x0023;

}

interrupt void sSciRxIsr(void)  //接收中断函数
{

     wSciRxTemp = SciaRegs.SCIRXBUF.bit.RXDT;

     PieCtrlRegs.PIEACK.all = PIEACK_GROUP9;

}

void  sSCITX(void)

{

  if(SciaRegs.SCICTL2.bit.TXRDY == 1)
  {   
   SciaRegs.SCITXBUF = wSciRxTemp;
  }

}

一周热门 更多>