-1

i am trying to add Basic Audio Output to a Raspberry Pi Zero 2W. I followed the same metod proposed in many tutorials using Device Tree Overlay :

1st step adding :

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4

in the /boot/firmware/config.txt

Then I just wanted to check the state of GPIO :

>sudo raspi-gpio get

it returns :

...
GPIO 12: level=0 alt=0 func=PWM0
GPIO 13: level=1 alt=0 func=PWM1
...

why GPIO12 and not GPIO18 ?

bbd 666
  • 109
  • 6

1 Answers1

0

My apologies I must have misread your question about what you did.

You have attempted to mix different pin combinations which are incompatible with audremap; you should use 12/13 OR 18/19.

Name:   audremap
Info:   Switches PWM sound output to GPIOs on the 40-pin header

Usage: dtoverlay=audremap,<param>=<val>

Params: swap_lr Reverse the channel allocation, which will also swap the audio jack outputs (default off) enable_jack Don't switch off the audio jack output. Does nothing on BCM2711 (default off) pins_12_13 Select GPIOs 12 & 13 (default) pins_18_19 Select GPIOs 18 & 19 pins_40_41 Select GPIOs 40 & 41 (not available on CM4, used for other purposes) pins_40_45 Select GPIOs 40 & 45 (don't use on BCM2711 - the pins are on different controllers)

One of the problems is raspi-gpio which states "raspi-gpio is deprecated - try pinctrl instead". It is no longer present in 64 bit OS and used to produce inconsistent results for different releases. It is not a reliable tool.

Read the documentation.

dtoverlay -h pwm-2chan
Name:   pwm-2chan

Info: Configures both PWM channels Legal pin,function combinations for each channel: PWM0: 12,4(Alt0) 18,2(Alt5) 40,4(Alt0) 52,5(Alt1) PWM1: 13,4(Alt0) 19,2(Alt5) 41,4(Alt0) 45,4(Alt0) 53,5(Alt1) N.B.: 1) Pin 18 is the only one available on all platforms, and it is the one used by the I2S audio interface. Pins 12 and 13 might be better choices on an A+, B+ or Pi2. 2) The onboard analogue audio output uses both PWM channels. 3) So be careful mixing audio and PWM. 4) Currently the clock must have been enabled and configured by other means.

Usage: dtoverlay=pwm-2chan,<param>=<val>

Params: pin Output pin (default 18) - see table pin2 Output pin for other channel (default 19) func Pin function (default 2 = Alt5) - see above func2 Function for pin2 (default 2 = Alt5) clock PWM clock frequency (informational)

Milliways
  • 62,573
  • 32
  • 113
  • 225