My Qt ( C++ ) application successfully dims the screen using the pigpio library on my Raspberry Pi compute module. It works great and is very stable using the code below. The problem, is that my previously working ALSA code that successfully played audio from the Pi is no longer working. I've read that this has to do with the pigpio library using DMA to achieve stable PWM timing.. Is there any way to have my cake and eat it too? Can I have ALSA work with PIGPIO's PWM? Thanks.

    while (!gpioInitialise()) {
        /// do something
    gpioSetPWMfrequency(SCREEN_PWM_BRIGHTNESS_PIN, 200);

    // Set the screen brightness to the new value
    qDebug() << "Setting Screen Brightness to: " << config.cabScreenBrightness();
    gpioPWM(SCREEN_PWM_BRIGHTNESS_PIN, (255 * config.cabScreenBrightness() / 100));

1 Answer 1


By default pigpio uses the PCM peripheral to time the DMA leaving the PWM peripheral free for standard audio.

Perhaps your ALSA device is using high quality audio. If that's the case you need to use the PWM peripheral to time the DMA leaving the PCM peripheral free for high quality audio.

To do that from C use gpioCfgClock.


gpioCfgClock(/* micros */ 5, /* PWM */ 0, 0);


You have to call gpioCfgClock before gpioInitialise.


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.