Hello everyone, I have a question about the SPI protocol. I have a project that requires the use of two devices:
- W5500 (ethernet module)
- nRF24L01 (2.4GHz radio module)
These two devices must communicate with a single arduino.
From what I understand, the SCLK, MOSI and MISO pins are in common for both, while the SS or CS pins must be changed according to the device that I have to use.
Now I have written a code to prove it works (both these devices are enabled on a low level):
#define PIN_W5500_SS 10
#define PIN_RADIO_SS 8
void loop() {
digitalWrite(PIN_RADIO_SS, HIGH);
digitalWrite(PIN_W5500_SS, LOW);
int packetSize = Udp.parsePacket();
if (packetSize) {
Udp.read(recvData, 5);
digitalWrite(PIN_W5500_SS, HIGH);
digitalWrite(PIN_RADIO_SS, LOW);
radio.write(recvData, 5);
}
}
What I do is to disable the unnecessary device and enable the one I have to request data from here.
Everything seems to work perfectly, but I have doubts:
- Do I have to set a delay after changing the SS pin, to allow time for the device to do its thing or is it okay even without it?
- In my case the change of the device happens very quickly (<10ms), can there be problems in the long run or not?
I hope I have been clear, thanks in advance.