-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Second call to i2s_adc_enable() always blocks (IDFGH-572) #2964
Comments
Hello, I've almost the same issue. I try to continuously acquire ADC data through the I2S but as soon as I activate the ADC (with i2s_adc_enable), the execution of my firmware is blocked (without errors or warnings in the monitor). My goal is to activate the ADC only once at initialization. I don't understand why I can't activate the ADC at startup and then let the DMA do its job on its side. Thank you for your help. |
Hi, @detly
|
Hi, @vgonet Can you provide more info? I think you and detly have encountered the same issue. thanks !! |
@koobest I don't understand. I don't disable the ADC before subsequent calls to |
@koobest Oh wait, I think I see what you're saying. Your logging statements show:
So it seems the ADC is disabled before the read is complete. Perhaps the call to |
Or maybe it's that it stops |
Alright, thanks to @koobest I figured it out. Of course FreeRTOS has all the tools needed to do this ie. a mutex around the static void i2s_read_task(void * arg)
{
main_data_t * data = arg;
bool printed = false;
bool keep_going = true;
do
{
size_t data_remaining = BUFFER_SIZE_BYTES;
keep_going = (xTaskNotifyWait(0, 0, NULL, 0) == pdFAIL);
(void) xSemaphoreTake(data->i2s_read_mutex, portMAX_DELAY);
while (data_remaining > 0)
{
size_t data_recd = 0;
ESP_ERROR_CHECK(
i2s_read(
I2S_NUM_0,
data->buffer, data_remaining,
&data_recd,
portMAX_DELAY)
);
data_remaining -= data_recd;
}
xSemaphoreGive(data->i2s_read_mutex);
if (!printed) {
show_some_data(data->buffer);
printed = true;
}
} while(keep_going);
vTaskSuspend(NULL);
} |
Environment
v3.3-beta1-223-ga62cbfec9
1.22.0-80-g6c4433a
Problem Description
In a program that uses the I2S direct-from-ADC capability, I can only call
i2s_adc_enable()
once before it blocks ie. the second time I call it, it never returns. So I can't switch this capability on and off as my program moves through different states.Expected Behavior
I would expect that if I call
i2s_adc_disable()
I would be able to calli2s_adc_enable()
again later, or at the very least I would get an error I can handle.Actual Behavior
A second call to
i2s_adc_enable()
results in the program not proceeding. There's no error or stack trace, just nothing else happens. I can't figure out from the docs if there are any other calls I need to make for this to work.Steps to reproduce
Check out the test code.
Build with
idf.py build
.Flash with
idf.py flash monitor
.You do not need anything connected to the ADCs to reproduce.
Code to reproduce this issue
See the test project on Gitlab (no login is required, it's public). The basic architecture is:
i2s_adc_enable()
xTaskCreate()
i2s_read()
in a loop and printing a small amount of the datavTaskDelete()
i2s_adc_disable()
i2s_adc_enable()
, "nothing" happens after thisBy "nothing" I mean: nothing more is printed to the log, and there's no visible errors eg. a stack trace or error indicating that a FreeRTOS call timed out, no processor exceptions, etc.
My guess is that it's hanging on trying to acquire the lock for the ADC, but that's released in an earlier call (to
i2s_adc_disable()
) as far as I can tell.The only example code I can find is in
examples/peripherals/i2s_adc_dac
, and that does a full reset of the chip in between connections. That's not an option in my project.Debug Logs
It just waits here until I do ctrl+]. Hours, if I leave it.
Other items if possible
The text was updated successfully, but these errors were encountered: