串口打印输出显示:SR=0xf,IER=0xb 但是没有进入数据溢出中断,这是为什么呢?
uint8 sja1000_init(void)
{
uint8 temp,state;
halDigioConfig(&pinALE);
halDigioConfig(&pinCS);
halDigioConfig(&pinRST);
halDigioConfig(&pinRD);
halDigioConfig(&pinWR);
memset(&canTxBuf,0,sizeof(canTxBuf));
memset(&canRxBuf,0,sizeof(canRxBuf));
halDigioClear(&pinRST);
halMcuWaitMs(100);
halDigioSet(&pinRST);
do
{
can_write_byte(SJA1000_PELI_MOD, SJA1000_PELI_MOD_AFM|SJA1000_PELI_MOD_RM);
can_read_byte(SJA1000_PELI_MOD,&state);
}
while(!(state&0x01));
can_write_byte(SJA1000_PELI_CDR, SJA1000_CDR_PELI_MOD|SJA1000_CDR_CLOCK_OFF);
can_write_byte(SJA1000_PELI_BTR0, 0x05);
can_write_byte(SJA1000_PELI_BTR1, 0x25);
can_write_byte(SJA1000_PELI_IER, SJA1000_PELI_IER_DOIE|SJA1000_PELI_IER_TIE|SJA1000_PELI_IER_RIE);
can_write_byte(SJA1000_PELI_OC, 0x1a);
can_write_byte(SJA1000_PELI_CMR, SJA1000_PELI_CMR_RRB);
can_write_byte(SJA1000_PELI_EWLR, 0xff);
for(temp=0; temp<4; temp++)
{
can_write_byte(SJA1000_PELI_ACC+temp, 0);
can_write_byte(SJA1000_PELI_ACM+temp, 0xff);
}
do
{
can_write_byte(SJA1000_PELI_MOD, SJA1000_PELI_MOD_AFM);
can_read_byte(SJA1000_PELI_MOD,&state);
}
while(state&0x01) ;
halDigioConfig(&pinCanInt);
halDigioIntConnect(&pinCanInt, &isr_can);
halDigioIntSetEdge(&pinCanInt, HAL_DIGIO_INT_FALLING_EDGE);
halDigioIntEnable(&pinCanInt);
asm("NOP");
halDigioIntClear(&pinCanInt);
return OK;
}
void isr_can(void)
{
uint8 temp,com,state_cmr;
can_read_byte(SJA1000_PELI_IR, &temp);
if(temp & 0x08) //数据溢出中断
{
mlib_console_Printf(" !!!!!!!!CAN RXFIFO OVERFLOW_ERR!!!!!!!!!!!! \r\n");
//执行 sja1000 清除数据溢出 命令
can_read_byte(SJA1000_PELI_CMR,&state_cmr); //读出命令寄存器状态
can_write_byte(SJA1000_PELI_CMR,(state_cmr|SJA1000_PELI_CMR_RRB|SJA1000_PELI_CMR_CDO)); //写命令寄存器,执行 清除数据溢出 命令
can_read_byte(SJA1000_PELI_ALC, &com);
can_read_byte(SJA1000_PELI_ECC, &com);
}
if(temp & SJA1000_PELI_IR_RI) //接收中断
{
if(DEBUG_OUTPUT_ON)
{
mlib_console_Printf(" isr_can ------Rx------GO \r\n");
}
isr_can_rx();
can_write_byte(SJA1000_PELI_CMR, SJA1000_PELI_CMR_RRB);
can_read_byte(SJA1000_PELI_ALC, &com);
can_read_byte(SJA1000_PELI_ECC, &com);
if(DEBUG_OUTPUT_ON)
{
mlib_console_Printf(" isr_can ------Rx------OK \r\n");
}
}
}
|