graydetroit
Well-known member
Hi,
My project is a MIDI sequencer, and I'm using two Teensy 4.1's. Here's a picture of the unit:
One Teensy handles the MIDI sequencer programming, MIDI output, USB host devices, and the button input processing.
The second Teensy handles updating the ILI9341 display. I did this because the display processing was often causing the MIDI clock to stutter, and I didn't want to mess around with threading. DMA didn't seem to help.
I'm using the ArduinoJson library to marshal my custom classes/data structures to serialized JSON, and to send them over the hardware Serial5 port to the second Teensy, and then the second Teensy deserializes and unmarshals the JSON back to the original classes/data structures to be used for display processing.
The problem is that after a certain amount of display updates with a JSON payload of around 3-5KB, the second Teensy freezes/crashes, presumably because there's a stack overflow or something like that. Here's an example JSON payload that the first Teensy sends to the second.
Here's the code. I'm sure I'm doing something extremely inefficient, and I'd be so appreciative if you can let me know how I can improve the code so that the memory usage doesn't become a problem so easily.
I tried using DMAMEM and I have the 8MB PSRAM chip on the second Teensy and I've tried initializing the dynamic JSON document buffer with EXTMEM, but nothing seems to work, I'm at my wit's end.
I can record a video of the behavior if that would help also.
Thanks so much in advance.
My project is a MIDI sequencer, and I'm using two Teensy 4.1's. Here's a picture of the unit:
One Teensy handles the MIDI sequencer programming, MIDI output, USB host devices, and the button input processing.
The second Teensy handles updating the ILI9341 display. I did this because the display processing was often causing the MIDI clock to stutter, and I didn't want to mess around with threading. DMA didn't seem to help.
I'm using the ArduinoJson library to marshal my custom classes/data structures to serialized JSON, and to send them over the hardware Serial5 port to the second Teensy, and then the second Teensy deserializes and unmarshals the JSON back to the original classes/data structures to be used for display processing.
The problem is that after a certain amount of display updates with a JSON payload of around 3-5KB, the second Teensy freezes/crashes, presumably because there's a stack overflow or something like that. Here's an example JSON payload that the first Teensy sends to the second.
Here's the code. I'm sure I'm doing something extremely inefficient, and I'd be so appreciative if you can let me know how I can improve the code so that the memory usage doesn't become a problem so easily.
I tried using DMAMEM and I have the 8MB PSRAM chip on the second Teensy and I've tried initializing the dynamic JSON document buffer with EXTMEM, but nothing seems to work, I'm at my wit's end.
I can record a video of the behavior if that would help also.
Thanks so much in advance.