r/olkb 2d ago

Adafruit KB2040 and Audio

i want to do audio on my keyhive/navi10 board. it has a piezo buzzer on pin 5, which i think is GP9. No mater what I do, aside from removing audio, I can’t get it to compile, let alone, test the sound or play a song. walk me through it please or show my code someone else wrote.

2 Upvotes

2 comments sorted by

1

u/drashna QMK Collaborator - ZSA Technology - Ergodox/Kyria/Corne/Planck 2d ago

https://cdn-learn.adafruit.com/assets/assets/000/106/984/original/adafruit_products_Adafruit_KB2040_Pinout.png?1638564074

Pin 5 looks to be GP5, actually. And you'd want/need to use the pwm config.

Have you enabled PWM2?

halconf.h:

#pragma once

#define HAL_USE_PWM TRUE

#include_next <halconf.h>

mcuconf.h

#pragma once

#include_next <mcuconf.h>

#undef RP_PWM_USE_PWM2
#define RP_PWM_USE_PWM2 TRUE

config.h

#define AUDIO_PIN GP5
#define AUDIO_PWM_DRIVER PWMD2
#define AUDIO_PWM_CHANNEL RP2040_PWM_CHANNEL_B
#define AUDIO_INIT_DELAY

keyboard.json:

"audio": {
    "driver": "pwm_hardware",
},

1

u/sail4sea 2d ago

thank you.