ESP32 FreeRTOS Crash after suspend task

I think if your can make it work using tasks is fine. Since it works once I think you can use it but don’t terminate the task, let the task listen to event and if it is signaled then exit the thread..

Use https://wokwi.com/ instead of Dropbox

So do you terminate the task or suspend it?

sorry, I can't upload library on wowki.

and sorry once again for making you confuse,
I have tried both suspend and delete tasks. to see how different.

for now, I can make it works by

  • put music play code into Task (core0) instead.
  • bring star field animation code back to the main loop (core1) so TFT will run with core 1 only.
  • I created a Task, let the music play, and delete the Task after finishing, everything worked.
    I can repeat create music play task and delete it several times without a problem.
    why don't suspend and resume task? I've tried but the music will continue play from the last position, so I delete task and create task to make it play from the start.

so by the conclusion, the TFT library should run on only 1 core.

thank a lot for your guide.

Just tried playing music and drawing stars at the same time on single core, the music is slow (in the simulator), so yes, probably using another core is the way to go StarsMega - Wokwi ESP32, STM32, Arduino Simulator

true, that's the point, nes music player generates 4 channel sounds and mix into 1 pin, so the music will be like there are 4 instruments playing simultaneously at a time. and consume a lot of CPU. it's unable to run another task while playing the music.