Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stm32,esp32: In machine_i2s, send null samples in underflow situations.
Eliminate noise data from being sent to the I2S peripheral when the transmitted sample stream is stopped. Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
- Loading branch information
1 parent
6d9da27
commit 0be3b91
Showing
2 changed files
with
4 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@miketeachman Unfortunately I can confirm that there is still "noise" being sent over the line after the ibuf empties. The difference now is that previously, when using async mode, it would endlessly repeat the entire buffer, but now it behaves in the same way as blocking and non-blocking mode, where it repeats only the first several bytes of the buffer, pauses a few ms, then repeats this twice before finally stopping. Here's a LA trace where I'm driving WS2812 LEDs with the i2s driver, similarly to the FastLED library. The gap between the main signal and the 3 additional ones corresponds to the part of the buffer that is empty. The workaround that I've found is to
deinit()
the entire i2s driver during that gap. Since I'm not sending a continuous stream, it might be appropriate for me to send some sort of explicit stop signal, but I currently have no way of knowing when the buffer is empty. I only know when the data has been finished copied from python code into the buffer (byawait
ing onstream.drain()
. So I need to guess based on the size of the buffer, the rate, and some slop for latency.I'm eager to help out fixing this, but honestly, the ESP32 docs on the i2s interface are very sparse. I can look into the FastLED library to see how they do it, when I get a chance.