tms320f28062 芯片,采用双串口工作,接收与发送都采用中断方式。SCIA 可正常工作,SCIB能正常发送,问题是SCIB接收数据不产生中断,请问一下,SCIB初始化配置有什么 需要注意的地方,与SCIA配配置有什么 不同?
Seven Han:
建议您先用示波器测下RX引脚看上位机是否有数据发过来。
gaoyang9992006:
TMS320F28335的串口有三个串口,SCIA,SCIB和SCIC,GPIO的管脚对应如下:SCIA对应GPIO28/29和GPIO35/36两组可选,SCIB有四组管脚可以选择,分别是GPIO9/11,GPIO14/15,GPIO18/19,GPIO22/23,SCIC对应的是GPIO62/63。首先需要定义管脚。void InitSciaGpio() //初始化GPIO管脚{ EALLOW;//根据硬件设计决定采用GPIO28/29和GPIO35/36中的哪一组。这里以35/36为例//定义管脚为上拉 GpioCtrlRegs.GPBPUD.bit.GPIO36 = 0; GpioCtrlRegs.GPBPUD.bit.GPIO35 = 0; //定义管脚为异步输入 GpioCtrlRegs.GPBQSEL1.bit.GPIO36 = 3; //配置管脚为SCI功能管脚 GpioCtrlRegs.GPBMUX1.bit.GPIO36 = 1; GpioCtrlRegs.GPBMUX1.bit.GPIO35 = 1; EDIS;}SCIB和SCIC的配置差不多。下来就要定义波特率等等了。例子是9600bps,1,8,n,1.void scia_init(){ 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 =0x0001; // 9600 baud @LSPCLK = 37.5MHz. SciaRegs.SCILBAUD =0x00E7; SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset}接着进行中断的配置 EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.SCIRXINTA = &sciaRxIsr; PieVectTable.SCITXINTA = &sciaTxIsr; PieVectTable.SCIRXINTB = &scibRxIsr; PieVectTable.SCITXINTB = &scibTxIsr; EDIS; // This is needed to disable write to EALLOW protected registers上面是将SCIA和SCIB的中断服务程序连到PIE的中断表中,发生中断就会跑到你的ISR去了下面就是开中断了。 PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable the PIE block PieCtrlRegs.PIEIER9.bit.INTx1=1; // PIE Group 9, int1 PieCtrlRegs.PIEIER9.bit.INTx2=1; // PIE Group 9, INT2 PieCtrlRegs.PIEIER9.bit.INTx3=1; // PIE Group 9, INT3 PieCtrlRegs.PIEIER9.bit.INTx4=1; // PIE Group 9, INT4 IER = 0x100; // Enable CPU INT EINT;
。。。。串口OK了
gaoyang9992006:
回复 Seven Han:
http://bbs.eeworld.com.cn/forum.php?mod=viewthread&tid=458579
另外参考此贴