#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;
}
各位大神,能帮我看看这个接收为什么进入不了中断吗? |