Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pico: "Fix" PWM audio clock div #771

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions 32blit-pico/audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#ifdef AUDIO_PWM
#include "pico/audio_pwm.h"
#include "hardware/clocks.h"
#include "hardware/pio.h"
#define HAVE_AUDIO
#define AUDIO_SAMPLE_FREQ 22050
Expand Down Expand Up @@ -87,9 +88,10 @@ void init_audio() {
if (!output_format) {
panic("PicoAudio: Unable to open audio device.\n");
}
#if OVERCLOCK_250
pio_sm_set_clkdiv(pio1, 1, 2.0f);
#endif

// PWM PIO program assumes 48MHz
pio_sm_set_clkdiv(pio1, 1, clock_get_hz(clk_sys) / 48000000.0f);

bool ok = audio_pwm_default_connect(producer_pool, false);
assert(ok);
audio_pwm_set_enabled(true);
Expand Down Expand Up @@ -152,4 +154,4 @@ void update_audio(uint32_t time) {
give_audio_buffer(audio_pool, buffer);
}
#endif
}
}