Using the .init
function for the ST7789 TFT screen prevents my WDT ISR from firing. What explains this behaviour, and is there something I can do? Any other timer ISR I could use instead?
#include <Adafruit_ST7789.h> // Includes Adafruit_GFX.h
#define TFT_CS 10 // define chip select pin
#define TFT_DC 9 // define data/command pin
#define TFT_RST 8 // define reset pin, or set to -1 and connect to Arduino RESET pin
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void setup()
{
//Serial.begin(9600);
pinMode(13, OUTPUT);
WDTCSR = (24); // Change enable and WDE - also resets
//prescalers only - get rid of the WDE and WDCE bit.
WDTCSR = (6); // 1 sec
WDTCSR |= (1 << 6); //enable interrupt mode - WDT as an interrupt is useful to wake up from sleep
sei();
tft.init(240, 240, SPI_MODE2); // comment this out and WDT works fine
tft.setRotation(0);
tft.setTextWrap(true);
}
void loop()
{
}
ISR(WDT_vect)
{
digitalWrite(13, (digitalRead(13) ^ 1)); // toggle LED pin
}
Thanks!
tft.init
is commented out?