2812使用外部30M晶振,SysCtrlRegs.PLLCR = 0x02, SysCtrlRegs.HISPCP.all = 0x0001;
SysCtrlRegs.LOSPCP.all = 0x0002; SYSCLKOUT=30M
串口配置:
void InitSci(void)
{
// Initialize SCI-A:
//*UART_MODE = 0x44;//232mode
*UART_MODE = 0xDD;//422mode
EALLOW;
GpioMuxRegs.GPFMUX.all = 0x0030;
EDIS;
/* loopback 8 bit data */
SciaRegs.SCICCR.all = 0x07;
SciaRegs.SCICTL1.all = 0x03;
SciaRegs.SCICTL2.all = 0x03;
SciaRegs.SCIHBAUD = 0x00;
//SciaRegs.SCILBAUD = 0xf3; //150M,19200
SciaRegs.SCILBAUD = 0x30; //30M,19200
SciaRegs.SCICTL1.all = 0x23;
PieCtrl.PIEIER9.bit.INTx1 = 1;
PieCtrl.PIEIER9.bit.INTx2 = 1;
//tbd...
// Initialize SCI-B:
//tbd...
}
采用中断方式:
interrupt void SCIRXINTA_ISR(void)
{
unsigned int tempdata;
tempdata=SciaRegs.SCIRXBUF.all;
UartProcess(tempdata);
// *Rx++ = tempData;
// RX_INFO_FLAG.rx_all=1;
PieCtrl.PIEACK.bit.ACK9 = 1;
EINT;
}
interrupt void SCITXINTA_ISR(void) // SCI-A
{
length--;
if(length>0) SciaRegs.SCITXBUF=*Tx++;
else
{
Tx=0;
length=0;
}
PieCtrl.PIEACK.bit.ACK9 = 1;
EINT;
}
void SendData(unsigned char * pt)
{
Tx=pt;
length=9;
length--;
if(length>0) SciaRegs.SCITXBUF=*Tx++;
else
{
Tx=0;
length=0;
}
}
/*设置中断服务程序入口地址*/
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TXAINT = &SCITXINTA_ISR;
PieVectTable.RXAINT = &SCIRXINTA_ISR;
EDIS; // This is needed to disable write to EALLOW protected registers
/*开中断*/
IER |= M_INT9;
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>