randyrossi / bmc64

A bare metal Commodore 64 emulator for the Raspberry Pi with true 50hz/60hz smooth scrolling, low input latency and better audio/video sync.
GNU General Public License v3.0
482 stars 55 forks source link

Question: Support for GPIO audio PWM module #264

Open aytekns opened 5 months ago

aytekns commented 5 months ago

Hi,

I've been using the BMC64 for a few months now and I'm enjoying every moment. Great project. I'm also planing to build, using 3D printer a Commodore 128D case for it and attach a small LCD screeen also mounted in a 3D printed retro screen case.

I bought a GPIO audio PWM expansion module but I do not know if BMC64 supports it and if so what are the configuration changes I need to apply to the different setting files for it to work.

Is it supported? If so, can you help me configure it?

Thanks, and again, great project,

mcgurk commented 5 months ago

In some cases dtoverlay setting can be used to get PWM audio from GPIO: https://wiki.batocera.org/audio_via_gpio_rpi_only

BMC64 uses Circle, so if Circle doesn't support it, BMC64 cannot support it. I'm pretty sure that Circle doesn't support audio from PWM-GPIO. Here is documentation about Circle GPIO-support: https://circle-rpi.readthedocs.io/en/46.0/basic-system-services/gpio-access.html

Investigate if Circle supports that module and after that we can continue discussion here. If Circle doesn't support, create issue to Circle: https://github.com/rsta2/circle

One option is to rewire that module to Raspberry Pi audio PWM-output pins, but that can be little unpractical. With Raspberry Pi Zero you need PWM0_OUT and PWM1_OUT, which are on GPIO 40 and 45 and are not brought out on the Pi Zero.

mcgurk commented 5 months ago

Hmm, here it says that PWM0_OUT and PWM1_OUT could be redirected to other GPIO pins: https://learn.adafruit.com/introducing-the-raspberry-pi-zero/audio-outputs

"You can get to PWM0 on GPIO 18 (ALT5) and PWM1 on GPIO 13 (ALT0) or GPIO 19 (ALT5)"

If it needs only GPIO alternate function, then it could be possible with Circle: https://circle-rpi.readthedocs.io/en/46.0/basic-system-services/gpio-access.html#initialization

aytekns commented 5 months ago

Hi, First, thank you @mcgurk for your reply. Before I investigate further I want to mention that I'm using Raspberry Pi 3B+ and not Zero. Would that make any difference?

I know I can use the RPi 3 audio jack (that's my backup plan) but I wanted to see if I can make use of the module I already bought.