结合自己调试的经验,这里做一个总结,uart的波特率参数需要通过计算来得到的,具体方法如下:
void scic_echoback_init()
{
// Note: Clocks were turned on to the Scib peripheral
// in the InitSysCtrl() function
ScicRegs.SCICCR.all =0x0007; // 1 stop bit, No loopback
// No parity,8 char bits,
// async mode, idle-line protocol
ScicRegs.SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK,
// Disable RX ERR, SLEEP, TXWAKE
ScicRegs.SCICTL2.all =0x0003;
ScicRegs.SCICTL2.bit.TXINTENA =1;
ScicRegs.SCICTL2.bit.RXBKINTENA =1;
#if (CPU_FRQ_150MHZ)
ScicRegs.SCIHBAUD =0x0000; // 115200 baud @LSPCLK = 37.5MHz.
ScicRegs.SCILBAUD =0x0027;
#endif
#if (CPU_FRQ_100MHZ)
ScicRegs.SCIHBAUD =0x0001; // 9600 baud @LSPCLK = 20MHz.
ScicRegs.SCILBAUD =0x0044;
#endif
ScicRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset
}
其中的ScicRegs.SCIHBAUD以及ScicRegs.SCILBAUD的计算方法如下:
?ScicRegs.SCIHBAUD = (37.5Mhz/(115200*8)-1)>>8 ?ScicRegs.SCILBAUD = (37.5Mhz/(115200*8)-1)&0xff
以下总结了几个常用的波特率的设置参数,供参考。
实际波特率 | SCIHBAUD | SCILBAUD | 300 | 3D | 08 | 600 | 1E | 83 | 1200 | 0F | 41 | 2400 | 7A | 00 | 4800 | 03 | CF | 9600 | 01 | E7 | 19200 | 00 | F3 | 38400 | 00 | 79 | 57600 | 00 | 50 | 115200 | 00 | 27 | 128000 | 00 | 23 | 256000 | 00 | 11 | 512000 | 00 | 08 |
参考博客:DSP F28335不同波特率参数设置_li707414287的博客-CSDN博客_dsp波特率
若有其他的问题,可以添加一下我们的群,希望有更多大家加入,一起讨论技术!
|