-1

This is the sample code in question: https://github.com/raspberrypi/pico-playground/tree/master/audio/sine_wave

I cannot see where it has set it's PWM output pin. Inside
"..pico-extras\src\rp2_common\pico_audio_pwm\include\pico\audio_pwm.h"
it has the following definitions:

#ifndef PICO_AUDIO_PWM_PIO
#ifdef PICO_AUDIO_PIO
#define PICO_AUDIO_PWM_PIO PICO_AUDIO_PIO
#else
#define PICO_AUDIO_PWM_PIO 0
#endif
#endif

#if !(PICO_AUDIO_PWM_DMA_IRQ == 0 || PICO_AUDIO_PWM_DMA_IRQ == 1)
#error PICO_AUDIO_PWM_DMA_IRQ must be 0 or 1
#endif

#if !(PICO_AUDIO_PWM_PIO == 0 || PICO_AUDIO_PWM_PIO == 1)
#error PICO_AUDIO_PWM_PIO ust be 0 or 1
#endif

Does this mean PWM can only be output from GPIO 0 or 1? In my current hardware setup I have to use GPIO 18 for PWM output. How do I change PWM output GPIO in this program?

Also, I cannot see PICO_AUDIO_PWM_PIO or PICO_AUDIO_PIO referenced anywhere in the sine_wave.c file linked above. How is the program assigning PWM to whatever GPIO that it is using?

--- Extra question:
I am a beginner in raspberry pi and if I correctly understood how it works, everything mentioned above is also doable using python. However, in their official github page I cannot find the python equivalent code for the sinewave generator linked above. Did they simply not provide a python version of this sample code, or did I misunderstand something about how the pico board works?

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Sep 1 '21 at 12:05
1

You need to look at the .c source code. The .h file is included into the .c source code to make the program.

Using the Pico PIO is an advanced topic. If you are intending to learn how to program I suggest you start by using the Pico GPIO block to generate your waveform. If you are not intending to learn how to program you need to hire a programmer familiar with the Raspberry Pico.

As with all software problems I suggest you start with a clear definition of what you want to achieve.

You can use the Pico GPIO block to generate software timed PWM on all the Pico GPIO. You can use the Pico PWM block to generate hardware timed PWM on all the Pico GPIO.

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.