完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
各為群上的先進您好
目前在下遇到的問題是在CAN 接收中斷內無法更新變數,但 MAIL BOX暫存器內的數值是會隨CAN BUS傳入的數值做變化 以下是在下的Coding #include "DSP28x_Project.h" // DSP281x Headerfile Include Fileint int0count = 0; // Counter to track the # of level 0 interruptsint int1count = 0; // Counter to track the # of level 1 interruptsvolatile unsigned int MLBX16_HD = 0;volatile unsigned int MLBX16_LD = 0;unsigned int MLBX17_HD = 0;unsigned int MLBX17_LD = 0;unsigned int message = 0;int elsecount = 0;interrupt void eCAN0INT_ISR(void);void ECan_MALBOX_INIT(void);struct ECAN_REGS ECanaShadow;void main()[ InitSysCtrl(); InitECanGpio(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); // Initialize the CAN module // InitECan(); //InitPieVectTable(); ECan_MALBOX_INIT(); EALLOW; // Configure CAN interrupts // ECanaShadow.CANMIM.all = 0xFFFFFFFF; //ECanaRegs.CANMIM.all = ECanaShadow.CANMIM.all; ECanaShadow.CANMIL.all = 0x00000000; // MBOX0 asserts MTOF0 (eCAN0INT) //ECanaShadow.CANMIL.bit.MIL0 = 1 ; // MBOX0 asserts MTOF1 (eCAN1INT) ECanaRegs.CANMIL.all = ECanaShadow.CANMIL.all; ECanaShadow.CANMIM.all = 0xFFFFFFFF; // Enable interrupts for all mailboxes ECanaRegs.CANMIM.all = ECanaShadow.CANMIM.all; //ECanaShadow.CANGIF0.all = ECanaRegs.CANGIF0.all; //ECanaShadow.CANGIF0.all = 0xFFFFFFFF; //ECanaRegs.CANGIF0.all = ECanaShadow.CANGIF0.all; //ECanaShadow.CANGIM.all = ECanaRegs.CANGIM.all; ECanaShadow.CANGIM.all = 0; ECanaShadow.CANGIM.bit.I0EN = 1; // Enable eCAN0INT //ECanaShadow.CANGIM.bit.I1EN = 1; // Enable eCAN1INT //ECanaShadow.CANGIM.bit.MTOM = 1; // Enable MBX Timeout interrupt ECanaRegs.CANGIM.all = ECanaShadow.CANGIM.all; PieVectTable.ECAN0INTA = &eCAN0INT_ISR; //PieVectTable.ECAN1INTA = &eCAN1INT_ISR; EDIS; PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enable vector fetching from PIE block PieCtrlRegs.PIEACK.bit.ACK9 = 1; // Enables PIE to drive a pulse into the CPU PieCtrlRegs.PIEIER9.bit.INTx5 = 1; // Enable INTx.5 of INT9 (eCAN0INT) //PieCtrlRegs.PIEIER9.bit.INTx6 = 1; // Enable INTx.6 of INT9 (eCAN1INT) IER |= M_INT9; // Enable INT9 of CPU EINT; // Global enable of interrupts //ERTM; for(;;) [ message = MLBX16_HD<<8; message |= MLBX16_LD; ]]void ECan_MALBOX_INIT()[ //struct ECAN_REGS ECanaShadow; // Config Transmit mail box ID // ECanaMboxes.MBOX0.MSGID.all = 0x80000501; // Extended Identifier ECanaMboxes.MBOX1.MSGID.all = 0x80000502; // ECanaMboxes.MBOX2.MSGID.all = 0x80000503; // ECanaMboxes.MBOX3.MSGID.all = 0x80000504; // ECanaMboxes.MBOX4.MSGID.all = 0x80000505; // ECanaMboxes.MBOX5.MSGID.all = 0x80000506; // ECanaMboxes.MBOX6.MSGID.all = 0x80000507; // ECanaMboxes.MBOX7.MSGID.all = 0x80000508; // ECanaMboxes.MBOX8.MSGID.all = 0x80000509; // ECanaMboxes.MBOX9.MSGID.all = 0x80000510; // ECanaMboxes.MBOX10.MSGID.all = 0x80000511; // ECanaMboxes.MBOX11.MSGID.all = 0x80000512; // ECanaMboxes.MBOX12.MSGID.all = 0x80000513; // ECanaMboxes.MBOX13.MSGID.all = 0x80000514; // ECanaMboxes.MBOX14.MSGID.all = 0x80000515; // ECanaMboxes.MBOX15.MSGID.all = 0x80000516; // // Config Receive mail box ID // ECanaMboxes.MBOX16.MSGID.all = 0x80000601; // ECanaMboxes.MBOX17.MSGID.all = 0x80000602; // ECanaMboxes.MBOX18.MSGID.all = 0x80000603; // ECanaMboxes.MBOX19.MSGID.all = 0x80000604; // ECanaMboxes.MBOX20.MSGID.all = 0x80000605; // ECanaMboxes.MBOX21.MSGID.all = 0x80000606; // ECanaMboxes.MBOX22.MSGID.all = 0x80000607; // ECanaMboxes.MBOX23.MSGID.all = 0x80000608; // ECanaMboxes.MBOX24.MSGID.all = 0x80000609; // ECanaMboxes.MBOX25.MSGID.all = 0x80000610; // ECanaMboxes.MBOX26.MSGID.all = 0x80000611; // ECanaMboxes.MBOX27.MSGID.all = 0x80000611; // ECanaMboxes.MBOX28.MSGID.all = 0x80000613; // ECanaMboxes.MBOX29.MSGID.all = 0x80000614; // ECanaMboxes.MBOX30.MSGID.all = 0x80000615; // ECanaMboxes.MBOX31.MSGID.all = 0x80000616; // // Write to DLC field in Master Control reg // ECanaMboxes.MBOX0.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX1.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX2.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX3.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX4.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX5.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX6.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX7.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX8.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX9.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX10.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX11.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX12.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX13.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX14.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX15.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX16.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX17.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX18.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX19.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX20.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX21.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX22.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX23.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX24.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX25.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX26.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX27.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX28.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX29.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX30.MSGCTRL.bit.DLC = 8; ECanaMboxes.MBOX31.MSGCTRL.bit.DLC = 8; // Configure Mailbox under test as a Transmit & Receive mailbox // ECanaShadow.CANMD.all = ECanaRegs.CANMD.all; ECanaShadow.CANMD.all = 0xFFFF0000; ECanaRegs.CANMD.all = ECanaShadow.CANMD.all; // Enable Mailbox under test // ECanaShadow.CANME.all = ECanaRegs.CANME.all; ECanaShadow.CANME.all = 0xFFFFFFFF; ECanaRegs.CANME.all = ECanaShadow.CANME.all;]interrupt void eCAN0INT_ISR(void) // eCAN[ if(ECanaRegs.CANRMP.bit.RMP16 == 1) [ int0count++; ECanaRegs.CANRMP.bit.RMP16 = 1; MLBX16_HD = ECanaMboxes.MBOX16.MDH.all; MLBX16_LD = ECanaMboxes.MBOX16.MDL.all; PieCtrlRegs.PIEACK.bit.ACK9 = 1; EINT; ] else if(ECanaRegs.CANRMP.bit.RMP17 == 1) [ int1count++; ECanaRegs.CANRMP.bit.RMP17 = 1; MLBX17_HD = ECanaMboxes.MBOX17.MDH.all; MLBX17_LD = ECanaMboxes.MBOX17.MDL.all; PieCtrlRegs.PIEACK.bit.ACK9 = 1; EINT; ] else elsecount++;] /*CANalyzer configuration file: 1M80SPRX.cfg... */ |
|
相关推荐
2 个讨论
|
|
只有小组成员才能发言,加入小组>>
NA555DR VCC最低电压需要在5V供电,为什么用3.3V供电搭了个单稳态触发器也使用正常?
692 浏览 3 评论
MSP430F249TPMR出现高温存储后失效了的情况,怎么解决?
605 浏览 1 评论
对于多级放大电路板,在PCB布局中,电源摆放的位置应该注意什么?
1064 浏览 1 评论
755 浏览 0 评论
普中科技F28335开发板每次上电复位后数码管都会显示,如何熄灭它?
529 浏览 1 评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
171浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
133浏览 14评论
在使用3254进行录音的时候出现一个奇怪的现象,右声道有吱吱声,请教一下,是否是什么寄存器设置存在问题?
129浏览 13评论
TLV320芯片内部自带数字滤波功能,请问linein进来的模拟信号是否是先经过ADC的超采样?
125浏览 12评论
GD32F303RCT6配置PA4 ADC引脚,将PA2代替key功能,PA2连接时无法实现预期功能,为什么?
62浏览 10评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 05:54 , Processed in 0.885190 second(s), Total 44, Slave 38 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号