Forum 2005-2010 (read only)
Syntax & Programs
(Read 3259 times)
May 19, 2009, 02:46 am
I've got an AY-3-8910 PSG sitting on my desk and an Arduino board on order. Now I know I need a 595 for the data inputs on the PSG and a few other pins for the other control pins.
My problem is that I have little to know idea how to go about programing the thing. I know that both the register address and the data input use the same pins and that the other control pins allow the selection between the two. All the documentation I have on the 8910 is rather vague on this important bit.
Does anyone have any experience with this or some insight?
May 20, 2009, 02:56 pm
I also have some AY-3-8910 chips, and used one extensively in the early 1980s (on a Compukit UK101). That main thing is to understand the BC1, BC2 and BDIR inputs. These pins are used to determine whether you're writing to the internal address latch, writing to the registers, or reading the registers. BDIR is simply the direction of the data bus, in or out (you'll probably only be writing, unless you want to read the I/O ports). I don't have the AY-3-8910 data sheet with me at the moment, but I have one at home. Will look it up! Do you have any specific questions, so far?
May 20, 2009, 06:21 pm
Thanks Anachrocomputer, as soon as I looked at datasheet I found the little truth table for the read/write functions. So that makes sense now.
The specific question: When programing this as a realtime instrument (instead of just playing back files) Would the loop look something like this:
set register 0;
set register 1;
May 23, 2009, 11:00 pm
: May 23, 2009, 11:01 pm by anachrocomputer
Yes, that's the basic idea, but of course if a register is unchanged from one step to the next, it need not be re-written. You'll probably end up writing a simple API (Application Programming Interface), where you will have functions to set the mixer up, set the envelope shaper up, set the frequency of each tone channel, and so on. Each of those will do a "set register/latch data" operation internally.
You'll also need a call to "delay ()" somewhere in that loop, to keep the timing reasonable. "delay ()" works in units of milliseconds.
May 27, 2009, 03:25 am
That sounds pretty good. I'm not sure how to write an API. Would it be something like the main loop asking for or waiting for a choice of what register to change?
May 28, 2009, 07:14 am
I, too, have experimented with the AY-3-8910 many years ago. I used to have a few of these in my parts box, but they were lost (along w/the datasheets for them) in a fire several years ago
To answer your question regarding "what is a API", it is true what Arachnocomputer said that it stands for "Application Programming Interface". This is simply a short way of saying "a collection of subroutines/functions that make interacting with the device (or whatever) a bit easier".
What this means in this instance is that it would be a good idea to start by creating a few functions that do basic operations on the AY-3-8910. Were I in your position, I'd start by writing two functions: PSGWriteRegister(reg, value) and perhaps Value = PSGReadRegister(reg). After you have these two functions in your "API", you could expand it by creating functions like PSGPlayTone(channel, frequency) and PSGSetMixer(). Functions like this would likely use the first two functions suggested above (e.g. PSGWriteRegister()). I don't remember enough about AY-3-8910's capabilities to suggest additional functions, but hopefully this will give you an idea what we mean when we speak of a "API".
Last IMHO comment: A well-designed API, that closely models the hardware that it is intended to control, and "abstracts" that hardware into a collection of functions/methods/classes that control various aspects of it can make programming a much less tedious task. The Wiring library (API) that is included in Arduino "sketches" is an example of a API that "abstracts" many of the capabilities of the AVR microcontroller and "hides" many of the gritty details involved in such things as setting up the timers for PWM generation, acquiring analog data using the ADC, performing input/output to the USART, and so forth. When you use functions such as Serial.init() and writeDigital() you are making use of the Wiring API.
May 28, 2009, 05:57 pm
If you want to play with them again, BG Micro has 8910s for about $4.00 each (datasheet included in their "Data" section):
Thanks for the explanation of API. I'm definately going to have to do a flow chart for this thing to make sure I have all the functioons down.