Here's how to generate a continuous fatal error exception with a suggested fix.
The setup is an OAK with 0.9.5 firmware with the Oak TFT LCD Shield. The SD card is wired to the appropriate SPI pins and SD_CS is on Pin 2.
The sketch is "digistump\hardware\oak\0.9.5\libraries\Adafruit_ILI9341\examples\spitftbitmap\spitftbitmap.ino" and the file purple.bmp from "
https://learn.adafruit.com/assets/13448" is copied to the SD card and renamed.
First the following changes are required to make the original sample work:
// OAK TFT LCD Shield:
#define TFT_DC 1
#define TFT_CS 6
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
#define SD_CS 2 // the pin I used
// the following function prototypes are needed to keep the Arduino IDE happy
void bmpDraw(char *filename, uint8_t x, uint16_t y);
uint16_t read16(File &f);
uint32_t read32(File &f); The example displays the image and is done. This version runs without issue.
However the following will cause a problem.
void setup(void) {
Serial.begin(115200);
tft.begin();
tft.fillScreen(ILI9341_BLUE);
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("failed!");
}
Serial.println("OK!");
bmpDraw("purple.bmp", 0, 0);
}
void loop() {
// the following three lines are added to give this example some activity
tft.fillScreen(ILI9341_BLUE);
bmpDraw("purple.bmp", 0, 0);
delay(500);
}With this version, the first image in setup displays as expected, but the image in loop is only partially drawn and the following is captured via the serial monitor:
ets Jan 8 2013,rst cause:2, boot mode:(3,0)
load 0x40100000, len 3632, room 16
tail 0
chksum 0xc0
load 0x3ffe8000, len 352, room 8
tail 8
chksum 0x82
csum 0x82
OakBoot v1 - N,BP,4
Initializing SD card...OK!
Loading image 'purple.bmp'
File size: 230456
Image Offset: 54
Header size: 40
Bit Depth: 24
Image size: 240x320
Loaded in 1713 ms
Loading image 'purple.bmp'
File size: 230456
Image Offset: 54
Header size: 40
Bit Depth: 24
Image size: 240x320
Soft WDT reset
ctx: cont
sp: 3fff29e0 end: 3fff2cb0 offset: 01b0
>>>stack>>>
3fff2b90: 000000f0 3fff1848 3fff18a4 402092d7
3fff2ba0: 04c4b400 00000001 0000012e 4020a650
3fff2bb0: 3f010000 ef000000 3fff1c38 40208fde
3fff2bc0: 000000f0 0000003c 00000078 0000003b
3fff2bd0: 000000f0 00000027 00000085 40207e59
3fff2be0: e99760f6 34cb914b 7d3bca7b c97d36c7
3fff2bf0: 5ef57b34 af8efc8f ffceb9ff 74ffa27a
3fff2c00: af92ffa0 f8af94fe a1fdac86 ba97ffc0
3fff2c10: fab185fe 57fa9957 a56afe9b 3ffe85f8
3fff2c20: 00000000 000003e8 1f001f00 70727570
3fff2c30: 622e656c 0000706d 00000200 3fff5800
3fff2c40: 0001c7d6 000000a2 0001b9c6 000002d0
3fff2c50: 00000140 00000001 00001ce1 00000140
3fff2c60: 00000001 00000003 3fff1c38 3fff1c7c
3fff2c70: 3fffdc20 00000000 3fff1c75 3fff1c7c
3fff2c80: 3fffdc20 00000000 3fff1c75 4020802c
3fff2c90: 00000000 00000000 3fff1c75 4020b9a2
3fff2ca0: 00000000 00000000 3fff1c90 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,0)
load 0x40100000, len 3632, room 16
tail 0
chksum 0xc0
load 0x3ffe8000, len 352, room 8
tail 8
chksum 0x82
csum 0x82
OakBoot v1 - W,BU,0
Fatal exception (0):
epc1=0x40225980, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Fatal exception (0):
epc1=0x40225980, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Fatal exception (0):
epc1=0x40225980, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
... ad nauseam ...
It appears that the Watch Dog TImer has not been satisfied by the long loading of two images. And then there is no recovery after the reboot.
Fortunately the Pin 1 Safe Mode recovers as expected to the triple blink, ready for download state.
Adding the following line to the bmpDraw function, the example does not have the fatal exception problem.
tft.pushColor(tft.color565(r,g,b));
} // end pixel
yield(); // in case this is a large file to process
} // end scanline
As always all comments, corrections, suggestions, improvements are welcomed.
Carl