On a Raspberry Pi 3 with as of today latest firmware and raspbian, I have e.g. espeak "hi" or aplay some.wav working after booting into a small loudspeaker plugged into the jack (this is headless, no X11 desktop; no HDMI monitor connected).

Now as soon as I use GPIO (e.g. https://github.com/pololu/dual-mc33926-motor-driver-rpi/blob/master/example.py to run a Motor), even after that's finished and released anything it has to release (or does it?), then sound won't work anymore (until I reboot); e.g. aplay fails with:

aplay: pcm_write:1939: write error: Input/output error

How are playing sound and GPIO related on the RPi, and what do you have to do you use both together?


The most likely clash is with GPIO 18/19/20/21 (pins 12/35/38/40).

PWM (medium quality audio) uses GPIO 18/19, PCM (high quality audio) uses GPIO 18/19/20/21.

Check to see what your motor driver is using which clashes and use alternative GPIO.

  • Aha. Yep, motor indeed uses e.g. RaspiBcmPin GPIO_12 (in Pi4j "BROADCOM_PIN_NUMBERING"), see [1] Motors driver class source. Using alternative GPIO on that [2] Motor shield appears to require to cut traces on the board and re-soldering... :-( There is no (easier) way to make PWM or PCM use another GPIO instead, is there? [1] github.com/vorburger/dual-mc33926-motor-driver-pi4j/blob/… [2] pololu.com/product/2755
    – vorburger
    Aug 21 '16 at 15:14
  • @vorburger I don't think you can alter the GPIO used for audio. But I do not use audio at all on the Pi so I may be wrong.
    – joan
    Aug 21 '16 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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