Page 1 of 1
CAN (Internal, MCP2515) Problem/Bug
Posted: Thu Jun 04, 2026 2:42 pm
by kennethnilsen69
Hi I have problems using the CAN component.
I will use both channels Internal1 and Internal2 on an ECIO40P16 (DSPIC33EP256MU806-IMR chip)
Here is the test I am doing:
http://ev-power.mine.nu/EV-POWER-NORWAY/FC/FC9_1.jpg
http://ev-power.mine.nu/EV-POWER-NORWAY/FC/FC9_2.jpg
see the attached project file
can1 works fine but can2 does not work. I need help and suspect that there is a fault/bug in the component.
I am using FC9 but get the same error in FC7
Re: CAN (Internal, MCP2515) Problem/Bug
Posted: Thu Jun 04, 2026 5:05 pm
by kennethnilsen69
Another problem is that if I initialize can2, can1 becomes very unstable and is unable to read can messages as it should.
Re: CAN (Internal, MCP2515) Problem/Bug
Posted: Thu Jun 04, 2026 8:19 pm
by kennethnilsen69
Just downloaded FC11 and same problem there
Re: CAN (Internal, MCP2515) Problem/Bug
Posted: Thu Jun 04, 2026 8:22 pm
by RGV250
Hi,
I was looking for code for a PIC24 device (not using FC) and found this which I recall the poster had a similar issue.
I have no idea how/if I can see the INIT code (which is where I think this code should be).
Anyway, this was the supposed fix, most is probably irrelevant but the bit I think might need to look at is the DMAxREQ value.
Use the same code for both modules. Switch the 1's to the 2's for the address names. For example, C1TR01CON for CAN1 becomes C2TR01CON for CAN2, etc.
Set up DMA1 for CAN transmit:
DMA1CONbits.SIZE = 0x0;
DMA1CONbits.DIR = 0x1; //From peripheral to DMA
DMA1CONbits.AMODE = 0x2;
DMA1CONbits.MODE = 0x0;
DMA1REQ = 70; <<<<<<<<<<<<<<<<<<<<<<<<< Change to 71 for CAN2
DMA1CNT = 7; //Data length
DMA1PAD = (volatile unsigned int) &C1TXD; //Point to peripheral register
DMA1STAL = (unsigned int) &CAN1MsgBuf; //Point to buffer
DMA1STAH = (unsigned int) &CAN1MsgBuf; //Point to buffer
DMA1CONbits.CHEN = 0x1; //Enable
Regards,
Bob