我的问题是这样的:
在串口中断服务程序中函数A,能正常进接收中断。但调用函数B则不能进接收中断。
我的上位机系统中共开启了三个中断:一个10ms定时器中断CPU TIMER0,一个250us定时器中断CPU TIMER2以及SCIB接收中断。
CPU TIMER0中断通过SCIB发送请求命令道下位机,下位机返回数据。通过示波器测量上位机SCIB的RX引脚能观测到数据(无论是调用函数A,还是调用函数B)。
SCIBRx ISR:
// Insert ISR Code here char i = 0; unsigned short tmp = 0; if(ScibRegs.SCIRXST.bit.RXERROR) { ScibRegs.SCICTL1.bit.SWRESET = 0; asm(" NOP"); asm(" NOP"); asm(" NOP"); ScibRegs.SCICTL1.bit.SWRESET = 1; } else { g_SCIBRxBuf.m_timeCnt = 0; i = ScibRegs.SCIFFRX.bit.RXFIFST; for(;i > 0;i--) {ReceivMsgA(); } ScibRegs.SCIFFRX.bit.RXFFINTCLR = 1; // Clear flag.PieCtrlRegs.PIEACK.all = PIEACK_GROUP9; }
串口初始化函数
void initSCI(volatile struct SCI_REGS *sci,unsigned long baud) { unsigned short brr; sci->SCICCR.all = 0x07;//One stop bit,No parity check,8 bits in every charactor. sci->SCICTL1.all = 0x43;//Enable TX,RX;Enable Rx error interruption. sci->SCICTL2.all = 0x02;//Enable Rx interruption and disable Tx interruption brr = ((SCI_IN_CLK + (baud << 2))/ (baud << 3)) - 1;//brr = LSPCLK / (baud * 8) - 1; sci->SCILBAUD = (unsigned char)brr; sci->SCIHBAUD = (unsigned char)(brr >> 8); sci->SCIFFTX.all = 0x401F; //Reset SCI,Reset Tx FIFO sci->SCIFFRX.all = 0x0000; sci->SCIFFCT.all = 0; sci->SCIPRI.all = 0x10; sci->SCIFFTX.all = 0xE01F; sci->SCIFFRX.all = 0x2021;//Resume RX FIFO,Enable Rx FIFO interruption,Whenever there is more than 1 bytes,//a interruption is generated. sci->SCICTL1.all = 0x63; //Enable if(sci == &SciaRegs) { EALLOW; GpioMuxRegs.GPFMUX.bit.SCIRXDA_GPIOF5 = 1; GpioMuxRegs.GPFMUX.bit.SCITXDA_GPIOF4 = 1; EDIS; PieCtrlRegs.PIEIER9.bit.INTx1 = 1; } else if(sci == &ScibRegs) { EALLOW; GpioMuxRegs.GPGMUX.bit.SCIRXDB_GPIOG5 = 1; GpioMuxRegs.GPGMUX.bit.SCITXDB_GPIOG4 = 1; EDIS; PieCtrlRegs.PIEIER9.bit.INTx3 = 1; } IER |= M_INT9; }
:
user1792825:调用函数A可以进中断,其实说明中断函数应该没问题,设置也是正确的,我觉得问题应该出在你的函数B上,检查函数B有没有数组或指针溢出什么的。