librpitx icon indicating copy to clipboard operation
librpitx copied to clipboard

I2S ADC stops working

Open hennichodernich opened this issue 2 years ago • 7 comments

As soon as the librpitx accesses the hardware, my I2S ADC stops working and only provides zeros.

I will investigate what happens on the I2S pins.

hennichodernich avatar Aug 10 '23 20:08 hennichodernich

As I remeber there is a i2s hacking method to have a fixe samplerate ussing it, but weird as the default method is pwm. https://github.com/F5OEO/librpitx/blob/dbb26b33c7630fe4e3690fbabfb6de0b019c05d2/src/gpio.cpp#L935

F5OEO avatar Aug 10 '23 21:08 F5OEO

It seems like the default method isn't pwm, but pcm, at least for fskburst and iqdmasync: https://github.com/F5OEO/librpitx/blob/dbb26b33c7630fe4e3690fbabfb6de0b019c05d2/src/iqdmasync.cpp#L48

hennichodernich avatar Aug 11 '23 13:08 hennichodernich

compiling with syncwithpwm=true causes the I2S audio to freeze during transmission, and the audio device needs to be reopened afterwards due to an I/O error.

hennichodernich avatar Aug 11 '23 15:08 hennichodernich

With syncwithpwm=false, PCM_CLK (GPIO 18) drops to 1/100 of the correct frequency, PCM_FS (GPIO 19) gets stuck at low. The audio device keeps running, but only outputs zeros. Reopening the audio device doesn't help.

With syncwithpwm=true, PCM_CLK keeps the correct frequency, PCM_FS gets stuck at low. The audio device stalls, and the application exits with I/O error. Reopening the audio device restores correct behaviour.

hennichodernich avatar Aug 11 '23 16:08 hennichodernich

It's this constructor: https://github.com/F5OEO/librpitx/blob/dbb26b33c7630fe4e3690fbabfb6de0b019c05d2/src/gpio.cpp#L937 It even gets called with syncwithpwm=true, because it's instantiated here unconditionally: https://github.com/F5OEO/librpitx/blob/dbb26b33c7630fe4e3690fbabfb6de0b019c05d2/src/fskburst.h#L8

hennichodernich avatar Aug 11 '23 19:08 hennichodernich

https://github.com/hennichodernich/librpitx/commit/6e0d9c6c1afcdd73579188a0c4308bf9d21113ba

Now works with pift8, but produces crackling noises with gr-rpitx.

hennichodernich avatar Aug 12 '23 13:08 hennichodernich

Solved. https://github.com/hennichodernich/librpitx/commit/abb967a699b540ca949c1c47455755358ec46167

Hesitating to create a PR, since PWM mode might not be a suitable default for all users.

hennichodernich avatar Aug 12 '23 18:08 hennichodernich