pierremolinaro / acan2515

MCP2515 CAN Controller Driver for Arduino
MIT License
74 stars 29 forks source link

can.tryToSend crashes when using rpi pico, with offical mbed rp2040 core #35

Open david284 opened 2 years ago

david284 commented 2 years ago

I have a raspberry pi pico, using Arduino official mbed rp2040 core framework-arduino-mbed 2.6.1 tool-rp2040tools 1.0.2 When I test the 'generic' LoopBackDemo sketch, my pico crashes on the can.tryToSend call and the LED blinks 4 short and 4 long and repeat. (the "LoopBackDemoRaspberryPiPico" doesn't compile with the offical mbed core, it seems to use other 'SPI' commands)

The "Configure ACAN2515" section runs fine and prints out the expected results (attached below)

So, I'm assuming the SPI is talking to the MCP2515 just fine?

If I comment out the can.tryToSend (with a true return) the loop runs fine

I saw a similar previous issue here but that crashed at can.begin(), which isn't my issue (my code runs past this command), so although I tried their work around, not surprisingly it didn't help ` Any idea what I could try or what to look at to resolve this?

Bit Rate prescaler: 4 Propagation Segment: 5 Phase segment 1: 5 Phase segment 2: 5 SJW: 4 Triple Sampling: yes Actual bit rate: 125000 bit/s Exact bit rate ? yes Sample point: 62% `

pierremolinaro commented 2 years ago

I did not succeed running a demo sketch with Arduino Mbed OS RP2040 Boards manager, release 2.6.1. I have updated to 3.0.1 without any success. Il always get a Configuration error 0x1, meaning the SPI cannot communicate with the MCP2515.

I use Earle F. Philhower board manager, it is very stable and I can select SPI pins easily.

Pierre

Le 30 mars 2022 à 18:51, david284 @.***> a écrit :

I have a raspberry pi pico, using Arduino official mbed rp2040 core framework-arduino-mbed 2.6.1 tool-rp2040tools 1.0.2 When I test the 'generic' LoopBackDemo sketch, my pico crashes on the can.tryToSend call and the LED blinks 4 short and 4 long and repeat. (the "LoopBackDemoRaspberryPiPico" doesn't compile with the offical mbed core, it seems to use other 'SPI' commands)

The "Configure ACAN2515" section runs fine and prints out the expected results (attached below)

So, I'm assuming the SPI is talking to the MCP2515 just fine?

If I comment out the can.tryToSend (with a true return) the loop runs fine

I saw a similar previous issue here https://github.com/pierremolinaro/acan2515/issues/31 but that crashed at can.begin(), which isn't my issue (my code runs past this command), so although I tried their work around, not surprisingly it didn't help ` Any idea what I could try or what to look at to resolve this?

Bit Rate prescaler: 4 Propagation Segment: 5 Phase segment 1: 5 Phase segment 2: 5 SJW: 4 Triple Sampling: yes Actual bit rate: 125000 bit/s Exact bit rate ? yes Sample point: 62% `

— Reply to this email directly, view it on GitHub https://github.com/pierremolinaro/acan2515/issues/35, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWKZVGDDABMLU4ND54XNSLVCSBCJANCNFSM5SCRVKPA. You are receiving this because you are subscribed to this thread.

david284 commented 2 years ago

I forgot to mention that I had to change the SPI pin assignments to match the 'default' SPI0 pins in the arduino header file in version 2.6.1, to get the SPI comms working at all

I've now changed to using the Earle F. Philhower core, and it's working fine, but obviously it takes more work to change to that core - although that does seem a much better core, with support for more of the features of the rp2040, like the ability to re-define pins and potentially the ability to use the 2nd core (not tried that yet though) It's best to share that this library doesn't currently work with the standard rp2040 core (I suspect because of limitations in the standard core, not the library), and you'll have to use the alternative core