Page 2 of 2

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Mon Jun 08, 2026 8:25 am
by kennethnilsen69
Thanks for the help so long. I understand that PIC16BIT_CAL_CAN.c is ok as you mentioned. But I don't understand this with interrupt and DMA.

To be able to send a can message out on can2 should be straight forward and work the same way as sending a can message out on can1. I'm not too concerned about what I can receive or how efficient I need to get can2 working first. When it works we can work on the efficiency and accuracy of it :-)

let's keep it very simple and get can2 to be able to send a message.

What's wrong with my test file since can2 doesn't work?

it's simple and straight forward, should work

I have this connected to a can bus that is monitored by canAnalyser software to see what happens when it tries to send ID 100 on can1 and ID 200 on can2

CAN1 works fine but CAN2 just gives an error on the bus and doesn't work

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Mon Jun 08, 2026 9:41 am
by BenR
Hello,

Your program all looks ok. The only key difference is can2 is half the speed of can1 which could potentially be causing the issues you're seeing with your analyser?

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Mon Jun 08, 2026 10:36 am
by RGV250
Hi,
I do not use FC for CAN but I always try it in "loopback" mode first to make sure there are no external influences.

If they are on the same BUS, where Ben pointed out they are different speeds I would expect CAN2 to set the error bit when CAN 1 is transmitting.

Have you tried CAN2 on its own?

Regards,
Bob

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Mon Jun 08, 2026 11:58 am
by kennethnilsen69
BenR wrote:
Mon Jun 08, 2026 9:41 am
Hello,

Your program all looks ok. The only key difference is can2 is half the speed of can1 which could potentially be causing the issues you're seeing with your analyser?
CAN1 is set to 500 bus rate and can2 is set to 250 bus rate which is what they should be :-)

I am making a can device that will communicate with 2 can buses at the same time. I have a car that has 2 different can buses with different bus rates :-)

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Tue Jun 09, 2026 11:02 am
by kennethnilsen69
This is the hardware I use. R3 and R4 are not used as this is connected to a bus that has 2 resistors in it.

I still can't get can2 to work.

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Tue Jun 09, 2026 1:14 pm
by RGV250
Hi,
A couple of thoughts.
Have you tried to run CAN2 in loopback mode.
If you put it in listen only mode are there errors when connected to the BUS.
Have you looked at the error counters.
Have you tried on it's own to the analyser with an end of line at the analyser.

Regards,
Bob

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Tue Jun 09, 2026 7:29 pm
by kennethnilsen69
Image

thanks for the help everyone. The problem is solved and the problem was 2 defective 120 resistors on the 250 kbit/s bus. with new resistor it worked :-)

I will start a new thread about the use of interrupt on CAN RX and the advantages of this. I would like to learn a little more about this

Re: CAN (Internal, MCP2515) Problem/Bug

Posted: Wed Jun 10, 2026 9:29 am
by Steve-Matrix
Great news!