Reading I2S data in ISR

physiii
Posts: 23
Joined: Fri Nov 17, 2017 9:37 pm

Reading I2S data in ISR

Postby physiii » Mon Feb 18, 2019 2:29 pm

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

ESP_Sprite
Posts: 9014
Joined: Thu Nov 26, 2015 4:08 am

Re: Reading I2S data in ISR

Postby ESP_Sprite » Tue Feb 19, 2019 3:09 am

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.)

Who is online

Users browsing this forum: bushpulbek and 109 guests