adamczykpiotr / pico-mcp2515

Raspberry Pi Pico MCP2515 CAN-Bus Interface Library
MIT License
75 stars 25 forks source link

Adding information what IO-pins to use #5

Closed StefanL38 closed 1 month ago

StefanL38 commented 9 months ago

Hi Adam,

I have looked for but did not find any information about which IO-pins are used for the SPI-interface. I am even more confused as the Pin-outs that can be found for the RP2040 pico show four sets of IO-pins that are named SPI-0.

Huh ? Now which IO-pins do I use? I guess the pico can not autodetect them.

RefreshMyMind-I commented 9 months ago

void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.print("MOSI: "); Serial.println(MOSI); Serial.print("MISO: "); Serial.println(MISO); Serial.print("SCK: "); Serial.println(SCK); Serial.print("SS: "); Serial.println(SS);
}

void loop() { // put your main code here, to run repeatedly: } You can use this sketch to find out in arduino ide.

adamczykpiotr commented 9 months ago

Hi! I believe there are no limitations in terms of which SPI_TX / SPI_RX pins you can use as long as they belong to the same SPI bus. So if you are using SPI0 you can use any of GP0 / GP4 / GP16 for RX and GP3 / GP7 / GP19 for TX.

Just to clarify things, TX in this context is MISO, RX = MOSI

https://www.raspberrypi.com/documentation/microcontrollers/images/pico-pinout.svg

adamczykpiotr commented 9 months ago

By default i am using what RPI Foundation suggest as default (defined here), so SPI0, SCK=18, TX = 19, RX = 16, CS = 17.

adamczykpiotr commented 9 months ago

It would be great if you could create a PR with updated repo or perhaps additional examples. I am currently quite time constrained in terms of my open source contributions but I'm glad to handle any PRs and help anyone creating them