CAN (Internal, MCP2515) Problem/Bug

For general Flowcode discussion that does not belong in the other sections.
Post Reply
kennethnilsen69
Posts: 38
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

CAN (Internal, MCP2515) Problem/Bug

Post 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
Attachments
CANTest1&2.fcfx
(17.67 KiB) Downloaded 7 times

kennethnilsen69
Posts: 38
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: CAN (Internal, MCP2515) Problem/Bug

Post by kennethnilsen69 »

Another problem is that if I initialize can2, can1 becomes very unstable and is unable to read can messages as it should.

kennethnilsen69
Posts: 38
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: CAN (Internal, MCP2515) Problem/Bug

Post by kennethnilsen69 »

Just downloaded FC11 and same problem there

RGV250
Posts: 453
Joined: Sat Mar 19, 2022 4:53 pm
Has thanked: 46 times
Been thanked: 46 times

Re: CAN (Internal, MCP2515) Problem/Bug

Post 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

Post Reply