-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore the PCM and PWM clock original states after using waves #567
Comments
Issue: joan2937#567 (WIP)
I'm preparing a pull request to address this. @joan2937 can you please have a quick look at dspinellis@93f127f to check if it's in the right direction? This is still work in progress. Currently the code is structured to save the hardware state of the five clocks, PWM, and PCM before modifying it, and to restore the saved state when |
This prevents pigpio wave output from disrupting sound output performed at a later point. Issue: joan2937#567
Most recent work is at https://github.com/dspinellis/pigpio/tree/fix-567-pm-state. Saving and restoring seems to work, and all original tests pass. I am currently looking at ways to add unit tests. |
Please explain the problem you encountered that motivated you to request this change. |
The issue is now correctly linked in the initial description and reproduced below. The following example program sends a short pulse on GPIO 14 using pigpio. import pigpio
pi = pigpio.pi() # connect to Pi
pi.wave_add_new()
pi.set_mode(14, pigpio.OUTPUT)
wf=[]
wf.append(pigpio.pulse(1 << 14, 0, 500))
wf.append(pigpio.pulse(0, 1 << 14, 800))
pi.wave_clear()
pi.wave_add_generic(wf)
wid = pi.wave_create()
pi.wave_send_once(wid)
while pi.wave_tx_busy():
pass
pi.wave_clear()
pi.stop() Even after terminating pigpiod, the sound from IQaudio sounds garbled: played intermittently at a high speed with vlc or sounding like white noise with speaker_test. Killing and rerunning pigpiod doesn't help. Only a reboot fixes the problem. Running pigpiod without running the program, or configuring pigpio without using its wave functionality doesn't create a problem. As explained in the answer to the corresponding Raspberry Pi StackExchange question, "pigpio takes over the PWM and PCM clocks when you use waves, and there is no provision made by pigpio to restore the clocks to the previous state." |
This prevents pigpio wave output from disrupting sound output performed at a later point. Issue: joan2937#567
Currently it appears that PCM and PWM clocks are taken over and not restored when using waves. Ideally, gpioTerminate should restore these clocks. My understanding is that this could be done by saving
clkReg[clkDiv]
before the call toinitClock(0)
and restoring it through calls toinitHWClk
.The text was updated successfully, but these errors were encountered: