I'd like to use a NRF24L01 radio along with a ST9720 display. The libraries I am using are U8g2lib and RF24. Both devices work when using them separately, with no other devices on the SPI bus. However, when try to add them in the same sketch, the display does not work at all. The devices are using different chip select lines.
This is my very beginning with the Arduino platform and I am not sure where to look, but possible lead is different frequency, which at the moment I am trying to gauge. I know that the radio uses 10 MHz clock, as defined in RF24_config.h.
Can someone chip in with ideas what to do?
Thanks
Edit: I am using Arduino Uno, NRF24L01 and ST9720.
I thought they would work. My code is below; the radio works, the display does not. When I disconnect the radio and remove the associated code, the display is fine.
#include <Arduino.h>
#include <U8g2lib.h>
#include <SPI.h>
#include <RF24.h>
U8G2_ST7920_128X64_1_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* CS=*/ 10, /* reset=*/ U8X8_PIN_NONE);
RF24 radio(7, 8); // using pin 7 for the CE pin, and pin 8 for the CSN pin
const byte address[5] = {'A', 'A', 'A', 'A', 'A'};
void setup(void) {
Serial.begin(115200);
u8g2.begin();
u8g2.clearBuffer();
u8g2.setFont(u8x8_font_7x14_1x2_f );
u8g2.drawStr(0,20,"Starting!");
u8g2.sendBuffer();
delay(1000);
if (!radio.begin()) {
Serial.println("Failed starting the radio!");
u8g2.clearBuffer();
u8g2.setFont(u8x8_font_7x14_1x2_f );
u8g2.drawStr(0,20,"Fail!");
u8g2.sendBuffer();
while (1) {}
}
Serial.println("Radio started!");
}
void loop(void) {
u8g2.clearBuffer();
u8g2.setFont(u8x8_font_7x14_1x2_f );
u8g2.drawStr(0,20,"OK!");
u8g2.sendBuffer();
delay(100);
}
The simple answer is that the ST7920 does not stop listening when CS is inactive.
However it looks as if you are trying to use SW_SPI on U8g2 and hardware SPI on RF24. You can never mix SW_SPI and HW_SPI. Even well behaved SPI devices must both use SW_SPI or both HW_SPI.
Just use HW_SPI for RF24 and bit-bang SW_SPI on different pins for ST7920.