Page 1 of 1

Reading I2S data in ISR

Posted: Mon Feb 18, 2019 2:29 pm
by physiii
Hello everyone,

I setup a 44,100 Hz timer to fill a buffer with data from an I2S microphone (SPH0645LM4H) however I get a core panic when running i2s_read_bytes() from inside the ISR, presumably it spends to much time there. Other methods I tried like running a simple task loop causes reliability issues and interferes with other parts of the program.

Can I read I2S data from the timer ISR? Or what is the preferred method for reading data continuously?

Andy

Re: Reading I2S data in ISR

Posted: Tue Feb 19, 2019 3:09 am
by ESP_Sprite
Don't call any functions that are non-trivial and not marked as ISR-callable (like the FreeRTOS *FromISR functions) in an ISR. Instead, handle the I2S reading in a task and use a semaphore to unblock the interrupt. (Or just spin a task to read the I2S data in the first place, i2s_read_bytes will block until there's data available so you don't actually need a timer if all you want is to read your microphone data.)