Teensy 4.0 Adafruit_SSD1306 and Adafruit_GFX crashes at boot

Status
Not open for further replies.

jofo

Member
Hi,
I am trying to use the Adafruit PiOled with Teensy 4.0 over I2C1.
The small PiOled display is a SSD1306 and thus using the SSD1306 library which extends Adafruit_GFX seems like a perfect choice.
I am using Teensduino 1.8.10 under Windows 10.

I have connected the pioled to pins 16&17 (SCL1, SDA1), (and to the 3v power pin and to gnd). Pins 16&17 are also connected with two 4.7kohm resistors to 3v.
Running the I2C scanner example, where I have replaced "Wire" with "Wire1" I can find the device on address 0xC3. So far so good.

The Adafruit_SSD1306 library (version 2.0.2 installed from menu, but also older versions and github versions of today for both ssd1306 and gfx, as well as this one) example however, compiles but crashes/freezes within the constructor of Adafruit_SSD1306(). It never reaches the setup() code. Below is a small example. If the Adafruit_SSD1306 line is removed the lights turns on. If present I can upload the code once, then nothing happens, and next time I upload I will have to
press the button to flash it.

Code:
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET    -1 // Reset pin # (or -1 if sharing Arduino reset pin)
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire1, OLED_RESET);

constexpr int ledPin = 13;
void setup() {
    pinMode(ledPin, OUTPUT);
    digitalWrite(ledPin, 1);
}
void loop() {
}

I have tried dig a bit deeper into it, removing code from the library. Maybe it comes furhter if I dont send the address to Wire1 but just use it directly in the lib. However then it seem to have trouble with the gfx library. So I am a bit stuck. Any suggestions welcome.
 
Status
Not open for further replies.
Back
Top