I am trying to use SPI1 on an Raspberry Pi PICO. SPI0 works fine, but I need SPI1 work. I have tried changing the pins around with no success. Please see code below and thank you for your at:tention:
#include <SPI.h>
#include <DW1000Ranging.h>
// Define the pins you are using for your DW1000 module's chip select (CS) and interrupt (IRQ)
const uint8_t PIN_SS = 13; // Example: GPIO 13 for CS (you can choose any available GPIO)
//const uint8_t PIN_IRQ = 14; // Example: GPIO 14 for IRQ (check your module's pinout)
// connection pins
const uint8_t PIN_RST = 9; // reset pin
const uint8_t PIN_IRQ = 2; // irq pin
//const uint8_t PIN_SS = SS; // spi select pin
void setup() {
Serial.begin(9600);
while (!Serial) delay(100);
SPI.begin();
// --- Configure SPI1 on RPi Pico ---
SPI1.setRX(12); // MISO on GPIO 12
SPI1.setCS(13); // CS on GPIO 13 (library will manage this, but good practice to set)
SPI1.setSCK(10); // SCK on GPIO 10
SPI1.setTX(11); // MOSI on GPIO 11
SPI1.begin(); // Initialize SPI1 bus
delay(333);
pinMode(13,OUTPUT);
digitalWrite(13, HIGH);
DW1000Ranging.initCommunication(PIN_RST, PIN_SS, PIN_IRQ); //Reset, CS, IRQ pin
//define the sketch as anchor. It will be great to dynamically change the type of module
DW1000Ranging.attachNewRange(newRange);
DW1000Ranging.attachBlinkDevice(newBlink);
DW1000Ranging.attachInactiveDevice(inactiveDevice);
//Enable the filter to smooth the distance
//DW1000Ranging.useRangeFilter(true);
//we start the module as an anchor
DW1000Ranging.startAsAnchor("82:17:5B:D5:A9:9A:E2:9C", DW1000.MODE_LONGDATA_RANGE_ACCURACY);
//delay(333);
}
void loop() {
// Your ranging loop code here
DW1000Ranging.loop();
}
void newRange() {
Serial.print("from: ");
Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), HEX);
Serial.print("\t Range: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRange());
Serial.print(" m");
Serial.print("\t RX power: ");
Serial.print(DW1000Ranging.getDistantDevice()->getRXPower());
Serial.println(" dBm");
}
void newBlink(DW1000Device* device) {
Serial.print("blink; 1 device added ! -> ");
Serial.print(" short:");
Serial.println(device->getShortAddress(), HEX);
}
void inactiveDevice(DW1000Device* device) {
Serial.print("delete inactive device: ");
Serial.println(device->getShortAddress(), HEX);
}
Doesn't work is not something we can work with. How do you know that? We need you to post the error information without interpretation, just show us what you see. Use code tags as well. BTW, next time you post code, get rid of all the unnecessary vertical white space and maybe run Tools/AutoFormat.
Thanks for your reply and my apologies. There are no error messages unfortunately. The DWM1000 anchor just does not interact with the tag when assigned to SPI1. It works fine when assigned to SPI0. Some peripherals libraries it seems don’t support SPI1.
True, I am trying to get my ENC28J60 Ethernet controller to operate on SPI1, but am running into challenges there too. I am wondering of I should change to another Ethernet controller. Thanks for your input.
It probably doesn’t. I need to find an Ethernet controller that does work on SPI1. I am finding challenges to get the ENC28J60 to do that. Should the ENC28J60 libraries may not support SPI1, would love to hear comments about alternative controllers. Thank you!
I am adding to the story, not changing it. I am trying to get something to work on SPI1, so that the DWM1000 can operate on SPI0. ENC28J60 libraries may not support SPI1 operation either, so I am going to look at using W5500 instead. I have no misgivings about the PICO board as of yet.
I'm going to take your topic literally. So here's an example of SPI1 working perfectly well on a Pico. Complete code and a picture of the wired circuit are provided below.
Why do you need to use a different SPI interfaces for your DWM1000 and Ethernet module? Do you know that SPI is a bus and you can connect a multiple modules to the single SPI interface?