I ran into an issue the other day when I finally gave in to the Arduino IDE asking if I wanted to update to the latest version. Recompiling the project I'm working on under Arduino 2.32, the Teensy to gets stuck in a reboot loop by apparently crashing when initializing the screen with a call to tft.begin().
I tried going back to Arduino 2.0.4, but the same problem persisted.
I tried installing Arduino 2.1.0 on a different computer and installing a slightly older version of Teensyduino (1.58.2), and that works fine -- no reboots.
Then I went back to the first computer and downgraded Teensyduino to 1.58.2 (Using Arduino 2.0.4) from 1.59.0, and that also works fine. So it seems like there was some sort of breaking change between 1.58.2 and 1.59.0.
Did something change in the ILI9341_t3.h library? Or something else that affects screen initialization?
A reproducer:
I tried going back to Arduino 2.0.4, but the same problem persisted.
I tried installing Arduino 2.1.0 on a different computer and installing a slightly older version of Teensyduino (1.58.2), and that works fine -- no reboots.
Then I went back to the first computer and downgraded Teensyduino to 1.58.2 (Using Arduino 2.0.4) from 1.59.0, and that also works fine. So it seems like there was some sort of breaking change between 1.58.2 and 1.59.0.
Did something change in the ILI9341_t3.h library? Or something else that affects screen initialization?
A reproducer:
#define hwversion 3
#include <ILI9341_t3.h>
#include <font_Arial.h>
#include <font_ArialBold.h>
/* Pins */
#define screenDCPin 9
#define sdiPin 11
#define sdoPin 12
#define sckPin 13
#define backlightPin 19
#define screenCSPin 255
/* Serial */
void serialSetup() {
Serial.begin(115200);
}
/* Screen */
#define TFT_DC screenDCPin
#define TFT_CS screenCSPin
#define TFT_RST 255 // 255 = unused, connect to 3.3V
#define TFT_MOSI sdiPin
#define TFT_SCLK sckPin
#define TFT_MISO sdoPin
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
uint32_t brightness = 127;
void screenSetup() {
Serial.println("in screenSetup");
pinMode(backlightPin, OUTPUT);
analogWriteFrequency(backlightPin, 3611*2); /* default is 3.611 kHz */
analogWrite(backlightPin, brightness);
Serial.println("about to call tft.begin, &tft = " + String((uint32_t)&tft));
delayMicroseconds(100000);
tft.begin();
Serial.println("got past tft.begin");
delayMicroseconds(100000);
tft.setRotation(1);
tft.setClock(100000000);
tft.fillScreen(ILI9341_BLACK);
Serial.println("was able to set rotation/clock and fill black");
//renderScreen();
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDPIXFMT);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDIMGFMT);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDSELFDIAG);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
Serial.println("5");
}
/* Setup, Main Loop */
void setup() {
serialSetup();
Serial.println("initializing screen...");
screenSetup();
Serial.println("end setup");
}
uint32_t usecs = 0;
uint32_t prevUsecs = 0;
uint32_t prevTimestamp = 0;
uint32_t screenRedrawAge = 1000000;
uint32_t maxRedrawAge = 10000;
void loop() {
Serial.println("main loop: if we got here, it's working");
delayMicroseconds(1000);
}