Closed elagil closed 4 months ago
I'm not familiar with SAI, but generally all drivers can be passed a &mut instance upon creation, and when the driver goes out of scope, it switches off the peripheral. Then you can reuse the peripheral with the driver next time you want to use it.
Thanks, I tried that and it works fine. I think I will stick with it.
Could you please elaborate on how you fixed that ? I'm running into the same issue with read() and I don't understand how to get rid of the overrun error
@I--P You can have a look at this implementation that I ended up with: https://github.com/blus-audio/firmware-rs/blob/main/blus_mini_mk2/src/audio_routing.rs#L325
When there is an error, a fresh SAI instance is created with new_sai4()
.
@elagil thanks a lot, that's what I ended up with too. It will be very helpful for many people to have a direct link to your code here.
Hello!
I use the
embassy_stm32::sai::SAI4
peripheral driver on theSTM32H723
for writing audio data to a TDM output.I have to start writing data immediately after calling
start()
on the driver instance - then it works fine. Otherwise, the writable ring buffer gives anOverrunError
, which I cannot recover from, because subsequent calls towrite()
also give that error immediately. The same happens when there is a pause in writing, and (I guess) that the DMA consumes all of the data in the ring buffer.I did not find a way to reset the ring buffer (and probably the driver itself). Do I have to make a new driver instance each time? Otherwise, I can also send zeros to the instance, to keep the buffer entertained, but I would rather be able to switch the peripheral off sometimes.
Thanks!