There are various examples how to read from an I2S microphone. eg: https://github.com/maspetsberger/esp32-i2s-mems
However, they all are using i2s_read() https://docs.espressif.com/projects/esp ... TickType_t which works perfectly fine but always blocks until the specified byte size has been read.
This is ok if you want to read a block of samples just for testing purpose, but for a real device I would expect to kick of the reading and would expect to get a call to an ISR everytime a block of samples has been transferred by the DMA.
Any idea how to achieve this?
What we have right now is a DMA that moves data from i2s peripheral to memory, but it blocks my operation in the main-loop.
I would expect the DMA not to blook my main loop.
Read from I2S without blocking call
-
- Posts: 9715
- Joined: Thu Nov 26, 2015 4:08 am
Re: Read from I2S without blocking call
You'd normally use a dedicated thread for reading the I2S peripheral, which then does whatever needs doing with the output data. You'd run other responsibilities in other tasks.
Re: Read from I2S without blocking call
Assuming i2s_read() is on thread A and the output via http is on thread B.
Both threads do not run at the same time, but only consecutively.
So you still und up with thread B not running because it needs to wait for the blocking call of i2s_read() in thread A to complete.
Both threads do not run at the same time, but only consecutively.
So you still und up with thread B not running because it needs to wait for the blocking call of i2s_read() in thread A to complete.
-
- Posts: 9715
- Joined: Thu Nov 26, 2015 4:08 am
Re: Read from I2S without blocking call
Well, first of all you can run the two threads in parallel, as you have two cores. Moreover, thread B can use some kind of signalling to indicate that it does not yet have any data buffered, allowing thread A to return immediately.
Re: Read from I2S without blocking call
Thank you very much, I was not aware I can choose the core my task is running at.
This solves all my questions
This solves all my questions
Who is online
Users browsing this forum: No registered users and 88 guests