I develop simple library for playing audio via DAC. In it, using task as data provider is very common pattern (it is very simple to use).
However, task watch dog is triggered very soon. I saw recommendation about turning off TWD completely, but requiring this to do for my library isn't very good, is it?
What is the best way to solve this problem? I use queue to transfer data from task to player function (called using `esp_timer`).
Thanks for your help !
TWD in low-latency task
Re: TWD in low-latency task
Some news: idle task isn't triggered on esp_timer core, not provider task.
Re: TWD in low-latency task
Most likely, your task is busy-waiting somewhere (ie polling in a while loop) so it always occupies the CPU and never allows the idle task to run. Try to find a way to block until an interrupt occurs, or until data is received via queue, that doesn't use polling. If you must use polling, find a place you can call vTaskDelay() in the polling loop.
If you're able to share your code, it may be possible to give more specific suggestions.
If you're able to share your code, it may be possible to give more specific suggestions.
-
- Posts: 9708
- Joined: Thu Nov 26, 2015 4:08 am
Re: TWD in low-latency task
Also note that the I2S driver allows you to send samples to the DAC without any CPU involvement at all, allowing you to play sounds while having nearly the full power of the CPU available to do other things. You may want to switch to that instead.
Re: TWD in low-latency task
At first, thanks for I2S suggestion. I know about it very well, but my library is for ones like me who don't want external device for playing some audio.
Now back to discussion:
It is pretty fun that library itself doesn't include mistake, but my test program does. This is how it looks:
Just added to while loop and it is working now!
If you want to look at library:
https://github.com/v1993/esp32-sound (Bug: https://github.com/v1993/esp32-sound/issues/4)
https://github.com/v1993/esp32-sound-pcm
Now back to discussion:
It is pretty fun that library itself doesn't include mistake, but my test program does. This is how it looks:
Code: Select all
#include <sound.h>
#include <soundProviderPcm.h>
#include <memory>
const extern long unsigned int voice_length;
const extern uint8_t voice_data[];
void play_voice() {
auto provider = std::make_unique<SoundProviderPcm>(voice_data, voice_length, 8000);
auto player = std::make_unique<SoundMixer>(1, 0, DAC_GPIO25_CHANNEL);
provider->repeat = true;
player->play(0, provider.get());
while (true) {};
}
extern "C" void app_main() {
play_voice();
}
Code: Select all
vTaskDelay(100);
If you want to look at library:
https://github.com/v1993/esp32-sound (Bug: https://github.com/v1993/esp32-sound/issues/4)
https://github.com/v1993/esp32-sound-pcm
Re: TWD in low-latency task
He means i2s will write to internal dac too.vyo2003 wrote:At first, thanks for I2S suggestion. I know about it very well, but my library is for ones like me who don't want external device for playing some audio.
Who is online
Users browsing this forum: No registered users and 93 guests