Open biemster opened 1 year ago
Maybe I hit something like this https://github.com/raspberrypi/pico-sdk/pull/971?
Printing some random stuff already fixes the issue, it does not have to involve head
or tail
.
I hacked my way around it by adding a stdio_flush()
on line 971, but I'd love to find a better solution here..
Hi @biemster , Things like this are usually caused by some timing issue. E.g. your call to printf() slows things down just enough to make the right thing happen at the right moment. Maybe a sleep call will produce the same effect.
This library is no longer updated, the efforts have been moved to the I2S library of the arduino-pico project: https://github.com/earlephilhower/arduino-pico/tree/master/libraries/I2S which starts from the same foundations and includes fixes and improvements.
So I'd strongly recommend to use that as your starting point.
Alternatively, you may want to have a look at the original MicroPython code to see if there's any update there: https://github.com/micropython/micropython/blob/master/ports/rp2/machine_i2s.c
Good luck!
Thanks @giampiero7 for your answer. I started of from the arduino-pico I2s library, but got stuck: https://github.com/biemster/pico-I2S, probably at the ping-pong DMA stuff (not my forte). I looked at the original MicroPython code as well indeed, but I don't see any relevant changes in that area, so that might have the bug as well..
This one's a doozy. I use your (great!)
machine_i2s.c
with the C-SDK like this:but I don't get any samples out without the most peculiar change: if I add on https://github.com/sfera-labs/arduino-pico-i2s-audio/blob/master/src/machine_i2s.c#L232 the following:
it suddenly starts spewing out correct frames! So it seems to me that the
printf
statement somehow materializes thehead
andtail
values, but my knowledge of the pico and or C is not nearly enough to start to understand this.