28335CAN接收为什么进不了中断?

2019-07-21 16:45发布

#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File

  interrupt void ECAN0INTB_ISR(void);
  Uint32 Rec_l0;
  Uint32 Rec_h0;

void main(void)
{
   struct ECAN_REGS ECanbShadow;

   InitSysCtrl();

   InitECanGpio();

   DINT;

   InitPieCtrl();

   IER = 0x0000;
   IFR = 0x0000;

    EALLOW;  
    PieVectTable.ECAN0INTB = &ECAN0INTB_ISR;       // TIMER0断向重定位
    EDIS;
   
    EALLOW;
    ECanbShadow.CANTIOC.all = ECanbRegs.CANTIOC.all;
    ECanbShadow.CANTIOC.bit.TXFUNC = 1;
    ECanbRegs.CANTIOC.all = ECanbShadow.CANTIOC.all;

    ECanbShadow.CANRIOC.all = ECanbRegs.CANRIOC.all;
    ECanbShadow.CANRIOC.bit.RXFUNC = 1;
    ECanbRegs.CANRIOC.all = ECanbShadow.CANRIOC.all;
    EDIS;
     
    ECanbRegs.CANME.all = 0;

    ECanbMboxes.MBOX16.MSGID.all = 0x9555AAA0;
  
    ECanbRegs.CANMD.all = 0xFFFF0000;
   
    ECanbRegs.CANME.all = 0xFFFFFFFF;

    ECanbMboxes.MBOX16.MSGCTRL.bit.DLC = 8;

    ECanbMboxes.MBOX16.MSGCTRL.bit.RTR = 0;

    EALLOW;
    ECanbRegs.CANMIM.all = 0xFFFFFFFF;
    ECanbShadow.CANMC.all = ECanbRegs.CANMC.all;
    ECanbShadow.CANMC.bit.CCR = 1;            
    ECanbRegs.CANMC.all = ECanbShadow.CANMC.all;
    EDIS;
   
    do
    {
      ECanbShadow.CANES.all = ECanbRegs.CANES.all;
    } while(ECanbShadow.CANES.bit.CCE != 1 );  
   
    EALLOW;
    ECanbShadow.CANBTC.all = ECanbRegs.CANBTC.all;

    ECanbShadow.CANBTC.bit.BRPREG = 9;    // (BRPREG + 1) = 10 feeds a 15 MHz CAN clock
    ECanbShadow.CANBTC.bit.TSEG2REG = 5 ; // to the CAN module. (150 / 10 = 15)
    ECanbShadow.CANBTC.bit.TSEG1REG = 7;  // Bit time = 15
    ECanbRegs.CANBTC.all = ECanbShadow.CANBTC.all;
   
    ECanbShadow.CANMC.all = ECanbRegs.CANMC.all;
    ECanbShadow.CANMC.bit.CCR = 0;            
    ECanbRegs.CANMC.all = ECanbShadow.CANMC.all;
    EDIS;

    do
    {
      ECanbShadow.CANES.all = ECanbRegs.CANES.all;
    } while(ECanbShadow.CANES.bit.CCE != 0 );

    EALLOW;
    ECanbShadow.CANMC.all = ECanbRegs.CANMC.all;
    ECanbShadow.CANMC.bit.STM = 0;    // Configure CAN for self-test mode  
    ECanbShadow.CANMC.bit.SCB = 1;    // eCAN mode (reqd to access 32 mailboxes)
    ECanbRegs.CANMC.all = ECanbShadow.CANMC.all;
    EDIS;
   
    EALLOW;
    ECanaRegs.CANMIM.all = 0xFFFFFFFF;     //邮箱中断屏蔽位
    ECanaRegs.CANMIL.all = 0;            //邮箱中断将产生在ECAN0INT
    ECanaRegs.CANGIF0.all = 0xFFFFFFFF;  //全局中断标志寄存器
    ECanaRegs.CANGIM.bit.I0EN = 1;   //ECAN0INT中断请求线被使能
    EDIS;

    PieCtrlRegs.PIEIER9.bit.INTx7 = 1;   //使能PIE中断
    IER |= M_INT9;                       //使能CPU中断
    EINT;
    ERTM;   

    for(;;)
    {

    }
}
  


// Begin receiving

interrupt void ECAN0INTB_ISR(void)  // eCAN-B
{
   while(ECanbRegs.CANRMP.all != 0x00010000 ) {}  // Wait for all TAn bits to be set..
       ECanbRegs.CANRMP.all = 0x00010000;   // Clear all TAn   
       Rec_l0 =  ECanbMboxes.MBOX16.MDL.all;
       Rec_h0 =  ECanbMboxes.MBOX16.MDH.all;
       PieCtrlRegs.PIEACK.bit.ACK9 = 1;
       ECanbRegs.CANOPC.all = 0;
       EINT;

}   

各位大神,能帮我看看这个接收为什么进入不了中断吗?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
6条回答
huhulai
2019-07-22 14:41
caowei0516 发表于 2014-6-19 16:46
在CANH和CANL之间并上一个电阻,问题已经解决。

楼主你好,我现在也出现了这个问题,请问你是怎么解决的。我的dsp开发板上,canh与canl已经并联了电阻了。

一周热门 更多>