This page will be for information for interfacing the General Instruments Programmable Sound Generator (PSG) Chips to the Z-80 also information for using it in other projects.
Just a couple of things, is the PSG was made for a multiplexed DATA/ADDRESS bus, some extra logic is required to interface it directly to the Z-80 or other then the processor General Instruments designed it for. My first example will be using the Datasheet example of using a PIO to interface with it, in my case the Z-80 PIO.
I have a link to the AY-3-8910 PSG in PDF format.
This is the example I am using from the Manual
Diagram of the internal PSG registers, make note that the registers are in Octal format. I made this mistake took me a while to figure out why the sound example did not work and values in examples are in Octal. R0-R7 translate as 0-7, but R10 = 8 in decimal, R11 = 9, R 12 = 10, and so on
This is the read/write assembly code example translated into C
I am interfacing via the Z80 PIO Port A: Data, Read/Write control port B: Port B bit 0 = BC1, Bit 1 = BC2, Bit 3 = BC3 or BDIR
If accessing the Sound chip via logic decoding, PIO code replaced with direct port number writes.
This code plays the example sound effect from the manual. Include files are found on PIO page, if you using from a terminal window replace my LCD print with printf.