Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RaspberryPi Pico(RP2040) with MCP2518FDClick #23

Open
rn-ksheer opened this issue Jun 6, 2024 · 4 comments
Open

RaspberryPi Pico(RP2040) with MCP2518FDClick #23

rn-ksheer opened this issue Jun 6, 2024 · 4 comments

Comments

@rn-ksheer
Copy link

Hi Pierre,

I was successful in using acan2517 lib on Arduino nano with MCP2518FDClick board as sender and UNO with MCP2515 as receiver. I am unable to do the same with pico development board, The program compiles and uploads without any errors but not receiving any frames at UNO side. I have read your pdf document and made the changes to use custom SPI pins, still no success. Please point the necessary settings required to make pico work with MCP2518FDClick.

`SPI.setRX(16);
SPI.setTX(19);
SPI.setSCK(18);
SPI.setCS(17);
SPI.begin();

ACAN2517Settings settings (ACAN2517Settings::OSC_20MHz, 500UL * 1000UL) ;
settings.mRequestedMode = ACAN2517Settings::Normal20B; // Select loopback mode`

@Koryphon
Copy link
Contributor

Koryphon commented Jun 6, 2024

Hello @rn-ksheer

These pins correspond to SPI1, not SPI (aka SPI0 according to the documentation)

Best regards

@rn-ksheer
Copy link
Author

rn-ksheer commented Jun 7, 2024

hi @Koryphon ,

The pins I have used are default SPI (SPI0),
Ref- arduino-pico & pico pinout.

When i disconnect any one of the SPI pins from pico , i get Configuration error 0x1 & when all pins are connected the below info gets printed on serial monitor which confirms lib is communication with pico.

sizeof (ACAN2517Settings): 32 bytes
Configure ACAN2517
MCP2517FD RAM Usage: 1024 bytes
Bit Rate prescaler: 1
Phase segment 1: 31
Phase segment 2: 8
SJW:8
Actual bit rate: 500000 bit/s
Exact bit rate ? yes
Sample point: 80%
Sent: 1
Sent: 2

I must be missing some other setting.
In ACAN2517.cpp, line 265 has mSPISettings = SPISettings (800UL * 1000, MSBFIRST, SPI_MODE0) ;
Does pico need clock speed adjustment here?

@Koryphon
Copy link
Contributor

Koryphon commented Jun 7, 2024

Oups. Sorry. I checked the PIN number instead of the GPIO number.

@rn-ksheer
Copy link
Author

Finally got it working !!
Since i used default SPI pins, defining pin numbers in void setup was not required, SPI.begin handels it.
Only if alternate pins are being used it has to be SET in void setup.
VIO SEL is set to 3v3 , STBY & STBY SEL are in their default position.
Tested with both 20MHz & 40MHz.

regards,
𝖱𝖾𝗇𝗎 𝖪𝗌𝗁𝗂𝗋𝗌𝖺𝗀𝖺𝗋

pico mcp2518FD
GP16 SDO
GP17 CS
GP18 SCK
GP19 SDI
GP20 INT
3V3 3V3
VBUS 5V
GND GND

pico_MCP2518FD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants