0

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()

It is run with pigpiod executed with these parameters in an attempt to minimize its interference with audio: pigpiod -l -m -t 0 -x 16384

Yet, 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.

Any ideas on how to restore the hardware's state after the wave output so that IQaudio sound works correctly?

2 Answers 2

3

There is no way provided by pigpio.

pigpio takes over the PWM and PCM clocks when you use waves. There is no provision made by pigpio to restore the clocks to the previous state.

1
0

The hardware PWM continues to run once it is set and the appropriate registers which control PWM & Clock can only be accessed by code with root access.
(I have never used PCM but the same would apply.)

It would be possible to write code which changes clocks but "restore" is more problematic as there is no default. Normally these are set (presumably by kernel) to a value to suit analog audio.

You could take a snapshot of the appropriate registers & restore values.

I know of no code to do this (other than the few libraries which support hardware PWM).

See https://forums.raspberrypi.com/viewtopic.php?p=2067934#p2067934 - this means the PWM Device Tree overlay is effectively useless as there is no support for setting clocks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.