刚做了一个28027的板子,跑TI SCI的例程发的都是乱码,帮看看是什么问题。 我用的是外部20M晶振。 DSP2802x_Examples.h文件中关于晶振与PLL的设置是如下: #define DSP28_DIVSEL 0 // Enable /4 for SYSCLKOUT #define DSP28_PLLCR 12 GPIO的设置如下: 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 = 1; // Enable pullup on GPIO29 GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // GPIO29 = SCITXDA 串口初始化: void scia_echoback_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 =0; SciaRegs.SCICTL2.bit.RXBKINTENA =0; SciaRegs.SCIHBAUD =0x0000; // 19200 baud @LSPCLK = 20MHz (60 MHz SYSCLK). SciaRegs.SCILBAUD =0x0081;
SciaRegs.SCICTL1.all =0x0023; // Relinquish SCI from Reset } void scia_msg(char * msg) { int i; i = 0; while(msg != '\0') { scia_xmit(msg); i++; } } // Initalize the SCI FIFO void scia_fifo_init() { SciaRegs.SCIFFTX.all=0xE040; SciaRegs.SCIFFRX.all=0x2044; SciaRegs.SCIFFCT.all=0x0; }
主函数: void main(void) { char *msg; InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000; IFR = 0x0000;
InitPieVectTable();
scia_fifo_init(); // Initialize the SCI FIFO scia_echoback_init(); // Initalize SCI for echoback for(;;) { msg = "\r\nEnter a character: \0"; scia_msg(msg); } }
|