Okay, I may not understand how tasks are blocked/ unblocked fully.
When I don't initialize the lower priority task, the wav player task runs without glitching. However when the other task is running, the wav task glitches.
The lower priority task reads a text file and parses it. The wav task reads 1024 bytes at a time from a wav file into a buffer of 1024 chars and then is written to the I2S buffer using I2S_write. Both tasks use fopen, fread ect with SPIFFS.
I have a question, if the lower priority task takes some time to execute before any calls to a function like vTaskDelay is called, would it block higher priority tasks? For example if the lower priority task had this code:
Code: Select all
void lowPriorityTask(void *parameters)
{
while(1)
{
for(uint32_t i = 0; i < 200000; i++){ }
vTaskDelay(1000);
}
}
And the high priority task was:
Code: Select all
void highPriorityTask(void *parameters)
{
// this loops a number of times, each time a new 1024 bytes of wavBuffer is to be written
...
i2s_write(I2S_NUM, (const char *)wavBuffer, 1024, &bytesWritten, portMAX_DELAY);
...
}
Would the high priority task interrupt the for loop while it is running to return from the I2S_write function in the high priority task?
If I understand correctly if you fill up the I2S buffer with I2S_write, the function will wait and return once there is room in the buffer to store more data?