Part Number:TMS320F28377D
如题,希望能够使用28377和板子上的RS485模块实现2.5MHz的串口通讯,但目前发现,改变LSPCLK为100MHz时,只有波特率为19200才能正常通讯。LSPCLK默认配置时,也有很多波特率无法正常工作。哪怕设置波特率为12500、1250这类理论上无误差的波特率,也无法正常通讯。
代码如下:
/*---------------------自定义头文件-----------------------------*/ #include "database.h" /*-----------------------函数申明-----------------------------*/ void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr); void delay (Uint16 t); void scia_xmit(int a); void scia_msg(char *msg); void scia_msg2(Uint16 *msg); /*-----------------------变量申明-----------------------------*/ Uint16 nBufIndex; Uint16 Buff_index; //=========================================================== Uint16 ReceivedChar; //接收暂存 char *msg; //发送暂存 //----------------------------------------------------------- void main(void) {InitSysCtrl(); //系统时钟初始化InitIpc();#ifdef _STANDALONE#ifdef _FLASH //Send boot command to allow the CPU02 application to begin executionIPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);#else //Send boot command to allow the CPU02 application to begin executionIPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);#endif#endif //-----------------------------------------------------InitGpio();DINT;IER = 0x0000;IFR = 0x0000;InitPieVectTable(); //--------------------外设初始化-----------------InitPeripheral(); //--------------------------------写FLASH程序-----------------------------------MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);InitFlash();PieCtrlRegs.PIEIER1.bit.INTx7 = 1;PieCtrlRegs.PIECTRL.bit.ENPIE = 1; //使能PIEIER |=(M_INT1);EINT; //----------------------------------------------------testing---------------------------------------------------EALLOW;GpioCtrlRegs.GPBMUX1.bit.GPIO36=0; //RS485输出输入选择 GpioCtrlRegs.GPBDIR.bit.GPIO36=1; ClkCfgRegs.LOSPCP.bit.LSPCLKDIV=1; //LSPCLK设为100MhzEDIS;GpioDataRegs.GPBSET.bit.GPIO36=1; //将RS485配置为发送ScibRegs.SCIHBAUD.all =0x0000; //LSPCLK=100MScibRegs.SCILBAUD.all =0x0004; //CLK=2.5M//// 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 protocolSciaRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,// Disable RX ERR, SLEEP, TXWAKESciaRegs.SCICTL2.all = 0x0003;SciaRegs.SCICTL2.bit.TXINTENA = 1;SciaRegs.SCICTL2.bit.RXBKINTENA = 1;SciaRegs.SCICCR.bit.LOOPBKENA = 1; // Enable loop backSciaRegs.SCICTL1.all = 0x0023;// Relinquish SCI from ResetSciaRegs.SCIFFTX.all = 0xE040;SciaRegs.SCIFFRX.all = 0x2044;SciaRegs.SCIFFCT.all = 0x0;for(;;){ scia_xmit(0x02); delay (50000); delay (50000);} //-------------------------------------------------------------- } void MemCopy(Uint16 *SourceAddr, Uint16* SourceEndAddr, Uint16* DestAddr) {while(SourceAddr < SourceEndAddr){*DestAddr++ = *SourceAddr++;}return; } void delay (Uint16 t) //延时函数 { Uint16 i;while(t--){for(i=0;i<125;i++)asm(" RPT #3 || NOP");} } void scia_xmit(int a) {while (ScidRegs.SCIFFTX.bit.TXFFST != 0) {}ScidRegs.SCITXBUF.all = a; }
Green Deng:
你好,问题收到,我需要咨询一下其他工程师,收到回复我会尽快更新到这里。
,
Zhou HaoYue:
非常感谢!期待您的回复。
,
Zhou HaoYue:
非常抱歉,我刚刚找到了错误,是我修改波特率时,寄存器选择错误。修改至正确的寄存器后,已经可以正常通讯。
,
Green Deng:
好的,感谢你的反馈!