Interrupt modes crash when accessing SPIFFS or Wifi
Closed this issue · 1 comments
Dear Matthias, thank you for all your work. You have been an inspiration for my interest in microcontrollers.
The part of your code that uses DMA interrupt works if used alone, but crashes when using SPIFFS and/or wifi, which is a big limitation for their use.
Your appreciation of the problem in #31 ("interrupt based version of the driver [...] needs a lot of cpu power") was no spot-on this time.
I tested it this way: initialized/connected SPIFFS or Wifi (with server) before vga.init. The microcontroller was stable (occasional crash) until a request to the server was done, or SPIFFS was accessed File root = FILESYSTEM.open("/","r");
.
Then, an exception was raised: Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)
The exception decoder showed that flash was being accessed (through SPI) (also happened in wifi usage, without SPIFFS), and the conflict was in the static function interrupt of the I2S object.
All documentation of the error pointed to lack of use of IRAM attribute for functions and DRAM for consts.
I tracked this error to several problems:
- Interrupt clearance through the i2s object was not safe
i2s.int_clr.val = i2s.int_raw.val;
. - A call to a member function was not safe (tested several options).
I worked out a solution, which is implemented in pull request #37.
Unfortunately wifi usage caused losing vSync and the screen needed some seconds to recover.
Thus, I further worked on a solution, to make hSync and vSync independent of the rendering routine in the interrupt, which is implemented in pull request #38. (You can ignore the previous pull request, which is there to provide you with understanding of the changes)
This code suffers only almost imperceptible glitches during wifi usage.
I hope that you find these changes interesting and worthwhile.
By the way, VGA6BitI had an error in
Line 150 in 222d953
which is also fixed.
This is included in the "development" branch here and eventually it will be merged into "master".