Skip to content

Commit

Permalink
pico: Hack PWM audio clock div
Browse files Browse the repository at this point in the history
  • Loading branch information
Daft-Freak committed Jun 2, 2022
1 parent 203bb9c commit 112c9b9
Showing 1 changed file with 6 additions and 4 deletions.
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
}
}

0 comments on commit 112c9b9

Please sign in to comment.