I've been using an SPI Sparkfun SSD1320 flexible OLED with an Arduino Nano Every and am successfully able to print to it, but when I try to switch from the Nano Every to a Nano 33 IoT, nothing prints to the display, despite the code uploading without issue. I'm just using some basic example code provided by Sparkfun as a test.
#include <SSD1320_OLED.h>
#include <SPI.h>
SSD1320 flexibleOLED(8, 9); //8 = CS, 9 = RES
void setup()
{
Serial.begin(115200);
SPI.begin();
flexibleOLED.begin(160, 32); //Display is 160 wide, 32 high
flexibleOLED.clearDisplay(); //Clear display and buffer
flexibleOLED.setFontType(1); //Large font
flexibleOLED.setCursor(28, 12);
flexibleOLED.print("Hello World!");
flexibleOLED.setFontType(0); //Small font
flexibleOLED.setCursor(52, 0);
flexibleOLED.print("8:45:03 AM");
flexibleOLED.display();
}
void loop()
{
}
I added the two lines for the SPI.h library and SPI.begin because the Every didn't seem to want to print without them. As mentioned above, this code uploads to the Nano 33 IoT perfectly fine. Just nothing gets printed to the display.
And my wiring is as follows:
I've tried wiring power from both the 5v pin and the 3.3v with the same issue either way.
Is there some additional coding I need specifically for this Arduino, or could this possibly have something to do with some kind of incompatibility with the SAMD21 CPU? I don't think the Arduino itself is faulty as I have a second Nano 33 IoT that had the same issue, and I've been able to successfully use it for a couple Blynk and basic GPIO (LED, push button, etc.) tests.
Just because you can load code does not mean that it will do what you want it to. All it means is that the compiler found no mistakes and the program that transfers code from the IDE to the processor worked.
It looks like in this case the different processors have different pins for the hardware SPI interface. That happens a lot when changing processors. While the software can cope with this you need to change your hardware wiring.
I'm aware, I just wanted to make clear that this wasn't due to any erroneous coding. My wiring is based on the pinout diagram found on the Nano 33 IoT overview page. I suppose my wiring for CS and RES could be wrong, but it was my understanding that any GPIO pin could be used for those. Is that not so? Or is there a need to specify in the code for those pins to do that?
I believe that 33 IoT diagram is wrong. UART protocol uses the Rx and Tx pins, and SPI uses SCK, MISO, and MOSI, not the other way around. I'm fairly certain I have my serial clock and data pins wired up correctly.
That is not so. There is a hardware SPI interface, maybe sometimes more than one in each processor. These are normally hard wired to specific pins and can't be changed. These are known as alternative GPIO uses. Some processors there are several alternative uses for each pin so it is not always possible to keep the same groups by software mapping alone.
The same is also true for UARTS, analogue inputs, PWM capable pins and the I2C bus.
You might have a bit of flexibility whereby there are alternative pins that can be attached to the one hardware unit, in which case you can only use one sets of pins to access that unit.
Connections seem right. It should not matter but, but in the example I can see they do not include SPI.h, but you do. May be this can be causing a problem with the CS pin. I found this pinout: