はっくはっくキッチン
Hack Hack Kitchen

PSG (AY-3-8910) Controller using AVR

 2021/11/21

PSG (AY-3-8910/YM2149) controller using AVR (prototype).

./AY-3-8910-banner.jpg

How it works

Wohl mir, dass ich Jesum habe - Jesus bleibet meine Freude (from Herz und Mund und Tat und Leben (BWV 147) by J. S. Bach)
Le Cygne (from Le Carnaval des animaux—Grande fantaisie zoologique by C. Saint-Saëns)

Introduction

There are many other similar projects, but I tried to control AY-3-8910 with AVR. There is nothing new here.

AY-3-8910 on a breadboard
AY-3-8910 on a breadboard
AY-3-8910 board
AY-3-8910 board

Schematic

./AY-3-8910-sch-thumb.png
Schematic of PSG Controller (click to enlarge)

Software

This project consists of the following programs.

psg-test.asm

A simple control program for testing. This can be used by itself.

psgplay.asm

Main program.

psgplay-commands.asm

Definitions of constants

tonedata.asm

Frequency data generated by bin/tone.pl.

musicdata.asm

Music data generated by bin/mmlc.pl.

bin/tone.pl

generates tone data corresponding to the specified PSG operating frequency

bin/mmlc.pl

generates binary data (as .db) from MML. This program is written in an uncommon way, because it is assumed to be rewritten in assembly language later.

The data is converted to binary and written in AVR in advance, and the AVR only sends the data to the PSG.

How to build

Fuse Setting

If you want to supply clock from AVR to PSG as shown in the circuit above, you need to set the fuse of AVR. In ATmega48 series, the 6th bit of Low Byte must be changed to 0 to enable CKOUT. Note that some devices (e.g. ATmega8) do not have CKOUT.

If a separate clock is supplied to the PSG, the fuse setting is not necessary.

If you are using avrdude, the specific steps are as follows. $(...) should be changed according to your own environment.

avrdude -c $(AVRWRITER) -p $(DEVICE) -b $(AVRDUDEBAUDRATE) -U lfuse:w:0x22:m

Build

Future work

  • Send MML to AVR via serial communication, convert to PSG data, and send it to PSG?

  • VGM format support?

License

  • MIT License