大家好
我在惯性导航系统中使用了TMS320f28335,开了T0,T1,T2 计时器,和SCIA,SCIB,SCIC接收中断,其中SCIC用于接收GPS信息,中断函数非常简洁,主要在主函数中处理GPS帧,但是有时候scic Rx中断正常,但有些时候不正常,不知道什么原因,请大家帮帮忙分析一下原因,谢谢。下面是SCIC初始化,SCIC中断接收,和主函数部分程序代码,完整的程序代码见附件.
void scic_init(Uint32 baudrate)
{
// Note: Clocks were turned on to the SCIC peripheral
// in the InitSysCtrl() function
// init GPIOs for SCI-C
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO63 = 0; // Enable pull-up for GPIO63 (SCITXDC)
GpioCtrlRegs.GPBPUD.bit.GPIO62 = 0; // Enable pull-up for GPIO62 (SCIRXDC)
GpioCtrlRegs.GPBQSEL2.bit.GPIO62 = 3; // Asynch input GPIO62 (SCIRXDC)
GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1; // Configure GPIO63 for SCITXDC operation
GpioCtrlRegs.GPBMUX2.bit.GPIO62 = 1; // Configure GPIO62 for SCIRXDC operation
EDIS; scic_fifo_init();
// Buad Rate BBR = LSPCLK(37.5MHz)/(BuadRate*8) – 1
baudrate = 37500000/(baudrate*8) – 1;
// 1 stop bit, No loopback
// No parity,8 char bits,
ScicRegs.SCICCR.all =0x0007;
// async mode, idle-line protocol
// enable TX, RX, internal SCICLK,
ScicRegs.SCICTL1.all =0x0003; // Disable RX ERR, SLEEP, TXWAKE
ScicRegs.SCICTL2.all =0x0003;
ScicRegs.SCILBAUD = baudrate & 0xff;
ScicRegs.SCIHBAUD = (baudrate>>8) & 0xff;
ScicRegs.SCICCR.bit.LOOPBKENA =0; // Disable loop back
// enable receive interrupt
ScicRegs.SCICTL2.bit.RXBKINTENA =1;
// enable transmit interrupt
ScicRegs.SCICTL2.bit.TXINTENA = 1;
// Relinquish SCI from Reset
ScicRegs.SCICTL1.bit.SWRESET = 1;
}
interrupt void scic_rx_isr(void)
{
unsigned char t;
while (ScicRegs.SCIRXST.bit.RXRDY)
{
t = ScicRegs.SCIRXBUF.bit.RXDT;
if (IsDirectGPS)
{
scia_xmit_ex(t);
} else
{
if (SCIC_RX_COUNT < SCI_RX_BUF_MAX)
{
SCIC_RX_BUF[SCIC_RX_COUNT++] = t;
SCIC_RX_NEW = TRUE;
}
}
}
// Acknowledge this interrupt to receive more interrupts from group 8
PieCtrlRegs.PIEACK.bit.ACK8 = 1;
}
main()
{
…
while(!(INS_Para.IsNoGPS))
{
if (SCIC_RX_NEW)
{
// if some new GPS data
CLOSE_SCIC_RX;
r = UBX_Addbytes(SCIC_RX_BUF, SCIC_RX_COUNT);
SCIC_RX_COUNT = 0;
SCIC_RX_NEW = FALSE;
OPEN_SCIC_RX;
…
}
…
}
…
}
mangui zhang:
先只开这一个中断 接收GPS的信号 看看是否正常
应该是多个中断影响造成的
中断里面只负责接收 然后标志通知主函数去处理