Datasheet ay-3-8910, AY-3-8912 Datasheet (Microchip Technology)

Page 1
Untitled
30-OCT-1999
This is the General Instruments AY-3-8910 / 8912 Programmable Sound Generator (PSG) data Manual.
This was scanned and converted using adobe capture and adobe acrobat to convert it into a .pdf.
Keep in mind that the OCR function is not perfect and you should be careful of typos and other errors introduced by the conversion process.
Page 1
Page 2
AY-3-8910/8912
PROGRAMMABLE
SOUND GENERATOR
DATA MANUAL
Page 3
Note: Registers are in Octal. Chart shown on page 11 shows
Channel A amplitude as “RIO”. In reality it is addressed as an “8”. “RI1” is really “9”;
“R12” is really “A” etc.
It has been found that the PSG works well in SIOO Buss
Applications using the system clock which by definition is 2MHZ.
“The 2MHZ should be divided by 2 to yield 1 MHZ to allow for lower
noise frequencies. This eliminates the need for an external clock as
shown on page 33. Note: Pages 3-4; 30, 31, 60-64 have been excluded. The booklet
does include all information available at this time.
Portions of this book have been reprinted with permission from the original General Instrument Ay-3-8910/8912 DATA MANUAL. Neither General Instruments nor this company assume responsibility for the accuracy or use of any of the information described herein.
Page 4
1 INTRODUCTION
It is apparent that any microprocessor is capable of producing acceptable sounds with only a transducer if the processor has no other tasks to perform while the sound is sustained. In real world microprocessor use, however, video games need refreshing, key-
boards need scanning, etc. For example, in order to produce a single channel of ninth octave C (8372 Hz) the signal needs attention every sixty microseconds. Software required to produce this simple effect and still perform other activities would in the least be very complex if not impossible. In the extreme, random noise requires periodic atten­tion even more frequently.
This need for software-produced sounds without the constant attention of the processor is now satisfied with the availability of the General Instrument AY-3-8910 and AY-3-8912 Programmable Sound Generators.
1.1
Description
The AY-3-8910/8912 Programmable Sound Generator (PSG) is a
Large Scale Integrated Circuit which can produce a wide variety of complex sounds under software control. The AY-3-8910/8912 is
manufactured in Gl’s N-Channel Ion Implant Process. Operation
requires a single 5V power supply, a TTL compatible clock, and a
microprocessor controller such as the GI 16-bit CP1600/1610 or one of Gl’s PIC 1650 series of b-bit microcomputers.
The PSG is easily interfaced to any bus oriented system. Its flexibility makes it useful in applications such as music synthesis, sound effects generation, audible alarms, tonesignalling and FSK modems. The analog sound outputs can each provide 4 bits of logarithmic digital to analog conversion, greatly enhancing the dynamic range of the sounds produced.
In order to perform sound effects while allowing the processor to continue its other tasks, the PSG can continue to produce sound after the initial commands have been given by the control processor. The fact that realistic sound production often involves more than one effect is satisfied by the three independently controllable channels available in the PSG.
All of the circuit control signals are digital in nature and intended to be provided directly by a microprocessor/microcomputer. This means that one PSG can produce the full range of required sounds with no change in external circuitry. Since the frequency responseof the PSG ranges from sub-audible at its lowest frequency to post­audible at its highest frequency, there are few sounds which are beyond reproduction with only the simplest electrical connections.
Since most applications of a microprocessor/PSG system would also require interfacing between the outside world and the microproces­sor, this facility has been designed into the PSG. The AY-3-8910 has two general purpose 8-bit I/O ports and is supplied in a 40 lead package; the AY-3-8912 has one port and 28 leads.
Page 5
1.2 > Full software control of sound generation. > Interfaces to most 8-bit and 16-bit microprocessors.
Features q Three independently programmed analog outputs.
> Two 8-bit general purpose I/O ports (AY-3-8910). > One 8-bit general purpose I/O port (AY-3-8912). > Single +5 Volt Supply.
13 This Data Manual is intended to introduce the techniques needed to
Scope
cause the AY-3-8910/8912 Programmable Sound Generator to per-
form in its intended fashion. All of the programs, programming, and
hardware designs have been tested to ensure that the methods are practical rather than purely theoretical.
Although the techniquesdescribed will produce powerful results, the
range of sounds to be synthesized is so vast and the PSG capabilities so varied that this guide should be viewed merely as an introduction to the applications possibilities of the PSG.
Fig. 1 TYPICAL SYSTEM DIAGRAM
Page 6
2 ARCHITECTURE
The AY-3-8910/8912 is a register oriented Programmable Sound Generator (PSG). Communication between the processor and the PSG is based on the concept of memory-mapped I/O. Control commands are issued to the PSG by writing to 16 memory-mapped
registers. Each of the 16 registers within the PSG is also readable so that the microprocessor can determine, as necessary, present states or stored data values.
All functions of the PSG are controlled through its 16 registers which once programmed, generate and sustain thesounds, thus freeing the system processor for other tasks.
2.1
An internal block diagram of the PSG showing the various functional
Basic
blocks and data flow is shown in Fig. 2.
Functional
Blocks
2.1.1 REGISTER ARRAY
The principal element of the PSG is the array of 16 read/write control registers. These 16 registers look to the CPU as a block of memory and as such occupy a 16 word block out of 1,024 possible addresses. The 10 address bits (8 bits on the common data/address bus, and 2 separate address bits A8 and *A9) are decoded as follows:
i
The four low order address bits select one of the 16 registers
(RO--
R17*).
The six high order address bits function as “chip selects” to
control the tri-state bidirectional buffers (when the high order address bits are “incorrect”, the bidirectional bulfers are forced to a
high impedance state). High order address bits A9 A8 are fixed in the
PSG design to recognize a 01 code; high order address bits
DA7--
DA4 may be mask-programmed to any 4-bit code by a special order factory mask modification. Unless otherwise specified, address bits
DA7--DA4
are programmed to recognize only a 0000 code. A valid high order address latches the register address (the low order 4 bits) in the Register Address Latch/Decoder block. A latched address will remain valid until the receipt of a new address, enabling multiple
reads and writes of the same register contents without the need for
redundant re-addressing.
Page 7
Page 8
Page 9
21
Basic
Functional
Blocks
(cont.)
Conditioning of the Register Address Latch/Decoder and the Bidi­rectional Buffers to recognize the bus function required (inactive, latch address, write data, or read data) is accomplished by the Bus Control Decode block.
The function of each of the 16 PSG registers and the data flow of each register’s contents are shown in context in Fig. 2 and explained in detail in Section 3, “Operation”. For reference purposes, the Register Array details are reproduced in Fig. 3.
2.1.2 SOUND GENERATING BLOCKS
The basic blocks in the PSG which produce the programmed sounds
include:
Tone Generators
Noise Generator
Mixers
Amplitude Control
Envelope Generator
D/A Converters
produce the basic square wave tone frequen­cies for each channel (A,B,C)
produces a frequency modulated pseudo random pulse width square wave output.
combine the outputs of the Tone Generators and the Noise Generator. One for each chan­nel (A,B,C). provides the D/A Converters with either a fixed or variable amplitude pattern. The fixed amplitude is under‘ direct ‘CPU control; the variable amplitude is accomplished by using the output of the Envelope Generator.
produces an envelope pattern which can be used to amplitude modulate the output of each Mixer. the three D/A Converters each produce up to a 16 level output signal as determined by the Amplitude Control.
2.1.3 I/O PORTS
Two additional blocks are shown in the PSG Block Diagram which
have nothing directly to do with the production of sound-these are the two I/O Ports (A and B). Since virtually all uses of microproces­sor-based sound. would require interfacing between the outside world and the processor, this facility has been included in the PSG.
Data to/from the CPU bus may be read/written to either of two 8-bit I/O Ports without affecting any other function of the PSG. The I/O
Ports are TTL-compatible and are provided with internal pull-ups on each pin. Both Ports are available on the AY-3-8910; only I/O Port A is available on the AY-3-8912.
Page 10
Page 11
2.2
PIN Assignments
The AY-3-8910 is supplied in a 40 lead dual in-line package with the pm assignments as shown in Fig. 4. The AY-3-8912 is supplied in a28
lead dual in-line package with the pin assignments as shown in Fig. 5.
Fig. 4 AY-3-8910 PIN ASSIGNMENTS
Page 12
/kage
with the
R
pplied in a 28 own in Fig. 5.
IANNEL
C
2.3 DA7--DA0 (input/output/high impedance): pins30--37 (AY-3-8910)
Pin Functions Data/Address 7-0:
pins 21--28 (AY-3-8912)
These 8 lines comprise the 8-bit bidirectional bus used by the microprocessor to send both data and addresses to the PSG and to receive data from the PSG. In the data mode, DA7--DA0 correspond to Register Array bits B7--B0. In the address mode, DA3-DA0 select the register # (O--178) and DA7--DA4 in conjunction with address inputs A9 and A8 form the high order address (chip select).
A8 (input): pin 25 (AY-3-8910)
pin 17 (AY-3-8912)
*A9 (input): pin 24 (AY-3-8910)
(not provided on AY-3-8912)
*Address 9, Address 8
These “extra” address bits are made available to enable the position­ing of the PSG (assigning a 16 word memory space) in a total 1,024 word memory area rather than in a 256 word memory area as defined by address bits DA7--DA0 alone. If the memory size does not require the use of these extra address lines they may be leftunconnected as each is provided with either an on-chip pull down (A9) or pull-up (A8) resistor. In “noisy” environments, however, it is recommended that A9 and A8 be tied to an external ground and +5V, respectively, if they are not to be used.
RESET
(input): pin 23 (AY-3-8910)
pin 16 (AY-3-8912)
For initialization/power-on purposes, applying logic “0” (ground) to the Reset pin will reset all registers to “0”. The Reset pin is provided with an on-chip pull-up resistor.
CLOCK (input): pin 22 (AY-3-8910)
pin 15 (AY-3-8912)
This TTL-compatible input supplies the timing reference for the Tone, Noise and Envelope Generators.
BDIR, BC2, BCl (inputs): pins 27,28,29 (AY-3-8910)
pins 18,19,20 (AY-3-8912)
Bus DIRection, Bus Control 2,l
These bus control signals are generated directly by Gl’s CP1600 series of microprocessors to control all external and internal bus operations in the PSG. When using a processor other than the CP1600, these signals can be provided either by comparable bus signalsor by simulating the signals on I/O lines of the processor. The PSG decodes these signals as illustrated in the-following:
Page 13
2.3
Pin Functions
(cont.)
While interfacing to a processor other than the CP1600 would simply
require simulating the above decoding, the redundancies in the PSG
functions vs. bus control signals can be used to advantage in that
only four of the eight possibledecoded bus functions are required by
the PSG. This could simplify the programming of the bus control
signals to the following, which would only require that the processor
generate two bus control signals (BDIR and BCl, with BC2 tied to
+5v):
Each of these signals is the output of its corresponding D/A Converter, and provides an up to 1V peak-peak signal representing
the complex sound waveshape generated by the PSG. IOA7--IOAO (input/output): pins 14--21 (AY-3-8910)
pins 7--14 (AY-3-8912)
IOB7--1OB0 (input/output): pins 6--13 (AY-3-8910)
(not provided on AY-3-8912)
Input/Output A7-- AO, B7-- B0
Each of these two parallel input/output ports provides 8 bits of
parallel data to/from the PSG/CPU bus from/to any external devices connected to the IOA or IOB pins. Each pin is provided with an on­chip pull-up resistor, so that when in the “input” mode, all pins will read normally high. Therefore, the recommended method for scan­ning external switches, for example, would be to ground the input bit.
Page 14
.
TEST 1:
pin 39 (AY-3-8910) pin 2 (AY-3-8912)
TEST
2: pin 26 (AY-3-8910)
(not connected on AY-3-8912)
These pins are for GI test purposes only and should be left open-& not use as tie-points.
Vcc:
pin 40 (AY-3-8910)
pin 3 (AY-3-8912)
Nominal +5Volt power supply to the PSG.
Vss:
pin 1 (AY-3-8910)
pin 6 (AY-3-8912)
Ground reference for the PSG.
2.4 Since the PSG functions are controlled by commands from the
Bus Timing
system processor, the common data/address bus (DA7--DAO) re­quires definition as to its function at any particular time. This is accomplished by the processor issuing bus control signals, previ­ously described, defining the state of the bus; the PSG then decodes these signals to perform the requested task.
The conditioning of these bus control signals by the processor is the same as if the processor were interacting with RAM: (1) the processor outputs a memory address; and (2) the processor either outputs or inputs data to/from the memory. The “memory” in this case is the
PSG’s array of 16 read/write control registers.
The timing relationships in issuing the bus control signals relative to the data or address signals on the bus are reviewed in general in the following section, and in detail in Section 7, Electrical Specifications.
Page 15
2.5 While the state flow for many microprocessors can be somewhat
State Timing
involved for certain operations, the sequence of events necessary to control the PSG is simple and straightforward. Each of the three major state sequences (Latch Address, Write to PSG, and Read from PSG) consists of several operations (indicated below by rectangular blocks), defined by the pattern of bus control signals (BDIR, BC2, BCl).
The functional operation and relative timing of the PSG control sequences are described in the following paragraphs (in all exam­ples, BC2 has been assumed to be tied to logic “1”, +5V).
2.5.1 ADDRESS PSG REGISTER SEQUENCE The “Latch Address.“. sequence is normally an integral part of the write or read sequences, but for simplicity is illustrated here as an
individual sequence. Depending on the processor used the program sequence will normally require four principal microstates: (1) send NACT (inactive); (2) send INTAK (latch address); (3) put address on bus: (4) send NACT (inactive). [Note: within the timing constraints detailed in Section 7, steps (2) and (3) may be interchanged.]
Page 16
2.5.2 WRITE DATA TO PSG SEQUENCE The “Write to PSG” sequence, which would normally follow immedi-
ately after an address sequence, requires four principal microstates: (1) send NACT (inactive); (2) put data on bus; (3) send DWS (write to PSG); (4) send NACT (inactive).
2.5.3 READ DATA FROM PSG SEQUENCE As with the “Write to PSG” sequence, the ”Read from PSG” sequence
would also normally follow immediately after an address sequence. The four principal microstates of the read sequence are: (1) send NACT (inactive); (2) send DTB (read from PSG); (3) read data on bus;
(4) send NACT (inactive).
2.5.4 WRITE TO/READ FROM l/O PORT SEQUENCE Since the two I/O Ports (A and B) each have an 8-bit register assigned
as a data store, writing to or reading from either port is identical to writing or reading to any other register. Hence, the state sequences are exactly-the same as described in the preceding paragraphs.
Page 17
3 OPERATION
Since all functions of the PSG are controlled by the host processor via a series of register loads, a detailed description of the PSG operation can best be accomplished by relating each PSG function to the control of its corresponding register. The function of creating or programming a specific sound or sound effect logically follows the control sequence listed:
Section
3.1
3.2
3.3
3.4
3.5
Operation
Registers
Function
Tone Generator Control
R0--R5
Program tone periods.
Noise Generator Control
R6
Program noise period.
Mixer Control
R7
Enable tone and/or noise on selected channels.
Amplitude Control
R10--R12 Select “fixed” or “envelope-
variable” amplitudes.
Envelope Generator
R13--R15
Program envelope period
Control
and select envelope pattern.
3.1 The frequency of each square wave generated by the three Tone
Tone Generator
Generators (one each for Channels A, B, and C) is obtained in the
PSG by first counting down the input clock by 16, then by further
Control
counting down the result by the programmed 12-bit Tone Period
value. Each 12-bit value is obtained in the PSG by combining the
(Registers R1, R2, R3, R4, R5)
contents of the relative Coarse and Fine Tune registers, as illustrated in the
following.
12-bit Tone Period (TP) to Tone Generator
Note that the 12-bit value programmed in the combined Coarse and Fine Tune registers is a period value-the higher the value in the registers, the lower the resultant tone-frequency.
Note also that due to the design technique used in the Tone Period count-down, the lowest period value is 000000000001 (divide by 1) and the hiqhest period value is 1111111‘11111 (divide by 4,09510).
Page 18
The equations describing the relationship between the desired output tone frequency and the input clock frequency and Tone Period value are:
Page 19
3.2
Noise Generator
CONTROL
(Register
R6)
The frequency of the noise source is obtained in the PSG by first counting down the input clock by 16, then by further counting down the result by the programmed 5-bit Noise Period value. This B-bit value consists of the lower 5 bits (B4-B0) of register R6, as illustrated in the following:
Noise Period
Register R6
Note that the 6-bit value in R11 is a period value-the higher the value in the register, the lower the resultant noise frequency. Note also that, as with the Tone Period, the lowest period value is00001 (divide by 1); the highest period value is 11111 (divide by 3110).
The noise frequency equation is:
Mix
Page 20
3.3 Register 7, is a multi-function Enable register which controls the
Mixer
Control-
three Noise/Tone Mixers and the two general purpose I/O Ports.
I/O Enable
The Mixers, as previously described, combine the noise and tone frequencies for each of the three channels. The determination of combining neither/either/both noise and tone frequencies on each
(Register R7)
channel is made by the state of bits B5--B0 of R7. The direction (input or output ) of the two general purpose I/O Ports
(IOA and IOB) is determined by the state of bits B7 and B6 of R7. These functions are illustrated in the following:
Mixer Control-I/O Enable
Register R7
Page 21
3.4 The amplitudes of the signals generated by each of the three D/A
Amplitude
Converters (one each for Channels A, B, and C) is determined by the contents of the lower 5 bits (B4--BO) of registers R10, Rl11, and R12 as
control
illustrated in the following:
Amplitude Control
(Registers R10, R11, R12)
Register #
Channel
R10
A
Rll
B
R12
C
amplitude
4-bit “fixed”
“Mode”
amplitude Level.
The amplitude “mode” (bit M) selects either fixed level amplitude (M=0) or variable level amplitude (M=1). It follows then that bits L3-­L0, defining the value of a “fixed” level amplitude, are only active when M=0. When fixed level amplitude isselected, it is “fixed” only in the sense that the amplitude level is under the direct control of the system processor (via bits D3--D0). Varying the amplitude when in this “fixed” amplitude mode requires in each instance the direct intervention of the system processor via an address latch/write data sequence to modify the D3--D0 data.
When M=1 (select “variable” level amplitudes), the amplitudeof each channel is determined by the envelope pattern as defined by the Envelope Generator’s 4-bit output E3 E2 E1 EO.
The amplitude “mode” (bit M) can also be thought of as an “envelope enable” bit; i.e., when M=0 the envelope is not used, and when M=1 the envelope is enabled. (A full description of the Envelope Gener­ator function follows in Section 3.5).
Page 22
Fig. 6
The full chart describing all combinations of the 5-bit Amplitude Control is as follows:
Amplitude Control
Register #
Channel
R10
A
R11
B
R12
C
Fig. 6 graphically illustrates a selection of variable level (envelope­controlled) amplitude where the 16 levels directly reflect the output of the Envelope Generator. A fixed level amplitude would correspond to only one of the levels shown, with the level directly determined by the decimal equivalent of bits L3 L2 L1 L0.
VARIABLE AMPLITUDE CONTROL (M=1)
Page 23
3.5
To accomplish the generation of fairly complex envelope patterns,
Envelope
two independent methods of control are provided in the PSG: first, it is possible to vary the frequency of the envelope using registers R13
Generator
and R14; and second, the relative shape and cycle pattern of the envelope can be varied using register R15. The following paragraphs
Control
explain the details of the envelope control functions, describing first
the envelope period control and then the envelope shape/cycle
(Registers R13, R14, R15)
control.
3.5.1
ENVELOPE PERIOD CONTROL (Registers R13, R14)
The frequency of the envelope is obtained in the PSG by first counting down the input clock by 256, then by further counting down the result by the programmed 16-bit Envelope Period value. This
16-bit value is obtained in the PSG by combining the contents of the Envelope Coarse and Fine Tune registers, as illustrated in the
following:
Note that the 16-bit value programmed in the combined Coarse and Fine Tune registers is a period value-the higher the value in the registers, the lower the resultant envelope frequency.
Note also, that as with the Tone Period, the lowest period Value is
0000000000000001 (divide by 1); the highest period value is
1111111111111111 (divide by 65,53610). The envelope frequency equations are:
Page 24
To calculate the values for the contents of the Envelope Period Coarse and Fine Tune registers, given the input clock and the desired envelope frequencies, we rearrange the above equations, yielding:
3.5.2 ENVELOPE SHAPE/CYCLE CONTROL
(Register
R15)
The Envelope Generator further counts down the envelope fre­quency by 16, producing a 16-state per cycle envelope pattern as defined by its 4-bit counter output, E3 E2 El E0. The particular shape and cycle pattern of any desired envelope is accomplished by controlling the count pattern (count up/count down) of the 4-bit counter and by defining a single-cycle or repeat-cycle pattern.
This envelope shape/cycle control is contained in the lower 4 bits
(B3--B0) of register R15. Each of these 4 bits controls a function in
the envelope generator, as illustrated in the following:
Envelope Shape/Cycle Control Register (R15)
The definition of each function is as follows: Hold
when set to logic “1”, limits the envelope to one cycle, holding the last count of the envelope counter (E3--
E0=0000 or 1111, depending on whether the envelope counter was in a count-down or count-up mode, respec­tively).
Alternate when set to logic “1”,
the envelope counter reverses
count direction (up-down) after each cycle.
NOTE: When both the Hold bit and the Alternate bit are ones, the
envelope counter is reset to its initial count before holding.
Page 25
3.5
Envelope
Generator
Control
(cont.)
Fig. 7
Attack when set to logic “1": the envelope counter will count up
(attack) from E3 E2 E1 E0=0000 to E3 E2 E1 E0=1111; when set to logic “0”, the envelope counter will count down (decay) from 1111 to 0000.
Continue when set to logic “1”, the cycle pattern will be as defined
by the Hold bit; when set to logic “0”, the envelope generator will reset to 0000 after one cycle and hold at that count.
To further describe the above functions could be accomplished by
numerous charts of the binary count sequence of E3 E2 E1 E0 for each combination of Hold, Alternate, Attackand Continue. However, since these outputs are used (when selected by the Amplitude Control registers) to amplitude modulate the output of the Mixers, a better understanding of their effect can be accomplished via a graphic representation of their value for each condition selected, as illustrated in Figs. 7 and 8.
ENVELOPE SHAPE/CYCLE CONTROL
Page 26
Page 27
3.6
Registers R16 and R17 function as intermediate data storage regis-
I/O Port Data
ters between the PSG/CPU data bus (DA0--DA7) and the two I/O ports (IOA7-IOA0 and
IOB7--1OB0).
Both ports are available in the
Store
AY-3-8910; only I/O Port A is available in the AY-3-8912. Using
registers R16 and R17 for the transfer of
I/O
data has no effect at all
(Registers R16, R17)
on sound generation. To output data from the CPU bus to a peripheral device connected
to I/O Port A would require only the following steps:
1. Latch address R7 (select Enable register)
2. Write data to PSG (setting B6 of R7 to “1”)
3. Latch address R16 (select IOA register)
4. Write data to PSG (data to be output on
I/O
Port A)
To input data from I/O Port A to the CPU bus would require the following:
1. Latch address R7 (select Enable register)
2. Write data to PSG (setting B6 to R7 to “0”)
3. Latch address R16 (select IOA register)
4. Read data from PSG (data from I/O Port A)
Note that once loaded with data in the output mode, the data will remain on the I/O port(s) until changed either by loading different data, by applying a reset (grounding the Reset pin), or by switching to
the input mode. Note also that when in the input mode, the contents of registers R16
and/or R17 will follow thesignals applied to the I/O port(s). However,
transfer of this data to the CPU bus requires a “read” operation as
described above.
Page 28
3.7 Since the primary use of the PSG is to produce sound for the highly
D/A Converter
imperfect amplitude detection mechanism of the human ear, the D/A conversion is performed in logarithmic steps with a normalized
Operation
voltage range of from 0 to 1 Volt. The specific amplitude control of each of the three D/A Converters isaccomplished by the three sets of 4-bit outputs of the Amplitude Control block, while the Mixeroutputs provide the base signal frequency (Noise and/or Tone).
Fig. 9 illustrates the D/A Converter output which would result if noise and tones were disabled and an envelope-controlled variable ampli­tude were selected.
Page 29
4 INTERFACING
4.1
Introduction
Since the AY-3-8910/8912 PSG must be used with support compo­nents, interfacing to the circuit is an obvious requirement. The PSG is designed to be controlled by a microprocessor or microcomputer, and drive directly into analog audio circuitry. It provides the link between the computer and a speaker to provide sounds or sound effects derived from digital inputs.
The following paragraphs provide examples and illustrations show­ing the ease with which an AY-3-8910/8912 Programmable Sound Generator may be utilized in a microprocessor/microcomputer system.
Fig. 14 SYSTEM BLOCK DIAGRAM
,
Page 30
4.2
An economical solution to providing a system clock is shown in Fig.
15. It consists of a 3.579545MHz standard color burst crystal, a
Clock
CD4089 CMOS inverter, and a CD4013 to divide the color burst
Generation
frequency in half. The clock produced for the PSG runs at a
1.7897725MHz rate. Depending on the microcomputer used, its clock should be selected within its specified value.
Fig. 15 CLOCK GENERATION
Page 31
4.3
Audio Output
Interface
Fig. 16
Fig. 16 illustrates the audio output connections to a commercially available LM386 audio amplifier. It shows channels A, B, and C summed together to enable complex waveforms to becomposed and amplified through a single external amplifier. These channels may be individually amplified through separate channels for more exotic sound systems.
Each output channel is individually controlled by separateamplitude
registers (R10, R11, R12) and an enable register (R7) in the PSG.
AUDIO OUTPUT INTERFACE
Page 32
4.4
The ROM or PROM shown connected to the PSG in Fig. 17 illustrates
External
an option for providing additional data information for processor support. The two I/O registers within the PSG are used in this case to
Memory
address the memory via I/O Port A (8 Bits) and read data from the memory via I/O Port B (8 Bits).
Access A
n
example of the bus control sequence to address and read an external memory connected to I/O ports A and B would be as follows (Assume Port A addresses and Port B reads):
Bus codes
Bus Control
BDIR BC2 BC1 Explanation of Bus Data (DA7--DA0)
Latch address
1 1
1
00000111: Latch R7 to program I/O Ports
Write to PSG
1 1
0 01000000: Set B7. B6 to 0, 1 respectively
Latch address
1 1
1
00001110: Latch R16 to address memory
Write to PSG
1 1
0 00000001: Address data to memory
Latch address
1 1100001111: Latch R17 to read memory
Read from PSG 0 11XXXXXXXX: Memory data contained in R17 NOTE: BC2 in the above Bus Codes may be permanently tied to +5V thus
requiring only two bus control lines for all control operations (refer to Section 2.3 for a complete explanation).
Also, RAM or EAROM may be used in place of the ROM or PROM shown by altering the program to use PORT B as an I/O. Port B then will be able to write data as an output and read data as an input.
Fig. 17 EXTERNAL MEMORY ACCESS
I
Page 33
4.5
In Fig. 18, the lines identified DA7--DA0 are the input/output bus bits
Microprocessor/
7--0. This 8 bit bus is used to pass all data and address information
between the AY-3-8910/8912 and the system processor.
Microcomputer
BC1, BC2 and BDIR are bus control signals generated by the
Interface
processor to direct all bus operations. These operations are identi­fied as Latch Address, Write to PSG, Read from PSG, and Inactive.
The following Sections detail specific interfaces to several popular
microprocessors/microcomputers.
Fig. 18 MICROPROCESSOR/MICROCOMPUTER INTERFACE
Page 34
4.6 Fig. 19 shows the schematic of an AY-3-8910 demonstrator circuit.
Interfacing
This configuration uses a PIC 1650 as the main controller in the circuit. The PIC 1650 is used to scan the keyboard, fetch data from the PROMS, writedata to the AY-3-8910 and provide the timing for the
to the PIC 1650
AY-3-8910.
The interfacing is direct since the PIC 1650 and the AY-3-8910 operate with compatible supplies and input/output voltages.
This particular schematic illustrates how a microcomputer with additional memory can produce a stand-alone music and sound effects circuit. The circuit as shown operates with manual keyboard selections.
As Fig. 19 shows, the design for the interface connects directly to the
output pins of the 1650 and the BC1, BC2, BDIR pins. The software
then has the responsibility of manipulating these signals to signal the
PSG to perform the proper address latch, read or write operations. The program routine in this section illustrates code which is used in a
hand-held demonstrator unit. This demonstration unit illustrates the range of PSG capabilities, including music, sound effects and I/O
control. Note that the generalized routines perform the address
latching before every read for convenience.
The “READ ROM” routine illustrates use of the generalized read and write routines to access the outside world through the PSG to read and write.
Page 35
4.6
Interfacing
to the PIC 1650
(Cont.)
Page 36
Fig. 19 PIC 1650/AY-3-6910 SYSTEM EXAMPLE
Page 37
4.7
As shown in Fig. 20, the wiring is direct between the AY-3-8910 and a
Interfacing to the
CP1600/1610 microprocessor. The levels are compatible thus elimi­nating any need for level converters. Even the terminology between
CP1600/1610
the IC’s remains constant to provide simple-to-follow connections. The CP1600/1610 acts as a controller in this configuration fetching
data from ROM’s contained elsewhere in the system. The CP1600/
1610 also acts as the bus controller developing the necessary timing
for the AY-3-8910.
4.7.1 WRITE DATA ROUTINE The program necessary to write to a selected register is as follows:
MVI value, R0; move in value to be written
MVO R0, Reg; write to register
The routine to load all registers with the same value is as follows:
MVII Reg 0, R4 CLRR R0
Here MVO@ RO, R4
CMPI Reg 0 + 17, R4 BLT Here
4.7.2 READ DATA ROUTINE The routine to read from a selected register is as follows:
MVI Reg, RO; get data from reg in R0 MVO R0, value; store in memory
Page 38
Fig. 20 CP1600/1610/AY-3-8910 INTERFACE
Page 39
4.8
An M6800 microprocessor can be interfaced with an AY-3-8910/8912
Interfacing
through the addition of an M6820 PIA chip. The I/O portsdesignated as PA0 to PA7 are used as the 8 bit bus lines and I/O ports PB0 to PB2
to the M6800
are used as the bus control lines. The software routines shown are used to control the latch address, write data, and read data functions for the AY-3-8910/8912.
4.8.1 LATCH ADDRESS ROUTINE ;AT ENTRY, B HAS ADDRESS VALUE
LATCH CLRA
STAA 8005 ;GET D DIR A LDAA #FF STAA 8004 ;OUTPUTS
LDAA #4 STAA 8005 ;GET PERIPHERAL A STAB 8004 ;FORM ADDR
STAA 8006
CLRA
STAA 8006 ;LATCH ADDRESS
RTS ;RETURN
4.8.2 WRITE DATA ROUTINE ;AT ENTRY, B HAD DATA VALUE
WRITE STAB 8004 ;FORM DATA
LDAA #6 ;DWS
STAA 8006
CLRA
STAA 8006 ;WRITE DATA
RTS ;RETURN I
4.8.3 READ DATA ROUTINE ;AFTER READ, B HAS READ DATA
READ STA A 8005 ;GET D DIR
STA A 8004 ;INPUTS LDAA #4 STA A 8005 ;GET PERIPHERAL DECA STA A 8006 ;READ MODE LDA B 8004 ;READ DATA CLRA STA A 8006 ;REMOVE READ MODE RTS ;RETURN
Page 40
Fig. 21 M6800/AY-3-8910 INTERFACE
Page 41
4.9
Interfacing
to the 8080
The sample S100 bus design provides for reading and writing the
PSG using only an 8080 “IN” or “OUT” instruction to the proper
address. Another feature of the design is the provision for multiple
PSG devices to be connected to a single bus. The system described is
presently running two PSG’s,
one
to each of
two
stereo channels.
S100 Bus
As can be seen from the read and write routines in the illustrative program, the program overhead necessary to communicate with the
PSG is minimal.
4.9.1 LATCH ADDRESS ROUTINE
PORTADDR EQU 80H ;ADDRESS TRANSFER PORT ADDRESS PORTDATA EQU 81H ;DATA TRANSFER PORT ADDRESS
THIS ROUTINE WILL TRANSFER THE CONTENTS OF ;8080 REGISTER C TO THE PSG ADDRESS REGISTER PSGBAR
MOV A,C ;GET C IN A FOR OUT
OUT
PORTBAR ;SEND TO ADDRESS PORT
RET
4.9.2 WRITE DATA ROUTINE
ROUTINETO WRITE THE CONTENTS OF 8080 REGISTER B ;TO THE PSG REGISTER SPECIFIED BY 8080 REGISTER C
PSGWRITE CALL PSGBAR ;GET ADDRESS LATCHED
MOV A.B, ;GET VALUE IN A FOR TRANSFER RET PORTDATA ;PUT TO PSG REGISTER
4.9.3 READ DATA ROUTINE
ROUTlNE TO READ THE PSG REGISTER SPECIFIED ;BY THE 8080 REGISTER C AND RETURN THE DATA ;IN 8080 REGISTER B
PSGREAD CALL PSGBAR
IN
PORTDATA ;GET REGISTER DATA MOV B,A GET IN TRANSFER REGISTER RET
Page 42
Page 43
5 MUSIC GENERATION
The production of music involves the creation of series of frequen­cies which are pleasing to the human ear (setting critical evaluation aside). This involves essentially mathematical relationships, making the application ideal for digital devices. For example, the shifting up or down in octaves is a multiplication or division by a power of 2, which is a simple shift operation for most microprocessors.
Another factor in music generation is “communication”. The com­poser must be able to convey his tune ideas so that a musician or group of musicians can reproduce the composer’s ideas-often on widely differing instruments. This concept involves “tuning” the instruments to a standard set of frequencies and following a set rhythm pattern. The tuning frequency most widely used is based on the third octave note “A” of 440Hz, the “Equal Tempered Chromatic Scale”.
Although it is easy to construct recognizable tunes using only one
note at a time, the simultaneous sounding of more than one note to produce chords and counterpoint vastly increases the quality of the sound. This feature is easily achieved in the PSG since three channels are provided, each independently programmable.
Note
5.1 Since notes are formed by sustaining a particular frequency for a
Generation
preset period of time at a varying amplitude, the PSG performs this
function with a series of simple register loads. The method used in
many cases is to obtain register load values for first octave notes and
to shift to the correct octave at playtime.
The chart in Fig. 23 lists a full 8 octaves of notes from a low of Cl (32.703Hz) to a high of B8 (7902.080Hz). Assuming an input clock
frequency of 1.78977MHz (one half the standard “color” crystal frequency of 3579545MHz), and applying the formulas of Section 3.1 for calculating Tone Period register load values, results in the
register values shown. The nature of the PSG divider scheme
produces a high degree of accuracy for low frequencies, less for high frequencies. This can be seen in the chart in the comparison of “ideal frequencies” and “actual frequencies”, with the ideal frequencies
being those of the Equal Tempered Chromatic Scale, and the actual
frequencies being the “best fit” values from the formula calculation.
Page 44
Page 45
5.2
Tune Entry/
Playback
53
Tune Variations
One of the methods of entering a composition into a computer memory would be to utilize a keyboard to pass number and alphabetic information concerning the composer’s wishes. An alter­nate method would be to scan a positional series of switches (like a
piano keyboard) to determine note, volume and duration data.
Since flexibility in tune entry is desired, it is important to allow the composer to specify certain constants of entry such as octave, pitch or tempo, and have these entries normalized to a known value.
One of the significant features of a microcomputer based music player is the ability to modify the tune once it has been recorded. Among the simpler variations are:
5.3.1 OCTAVE SHIFT
If an octave constant is added to the octave of the recorded note prior
to storing the value in the PSG register, dynamic pitch changes can
be obtained. The programming effect would be to shift one bit left for each lower octave and one bit right for each higher octave. For example, the effect will be that a tune written to play on a piano will sound like bells if a multiple octave up modification is performed.
5.3.2 KEY
One measure of the virtuosity of a musician is his ability to modify the “key” or suboctave shift of a composition. The logical description of key transposition is to shift each note up or down by a predetermined
number of notes from the original. For example, a piece written in C
and played in C# would have all C notesshifted to C#, C# shifted to D, etc. (Note that the case must be considered where B of one octave is shifted to C of the next higher octave.) All of theseoperations require that the one of twelve note identification must be retained in the recorded representation.
5.3.3 TEMPO
The duration of each recorded note is best expressed in terms of “ticks” of an overall “tempo clock”. At playtime, the total duration can be obtained by programatically multiplying the individual note to “slow down” or “speed up” the tune without changing the crucial time relationship between the notes. This can be accomplished by imbedding the note timing loops within the tempo timing loops for simple operation.
Page 46
5.3.4 CHORDS There are-certain combinations of notes which when played simul-
taneously produce pleasant combinations. These “chords” can be easily formed from a base note by performing octave and key changes on two notes, which are played with the main note. These
relationships are illustrated in Fig. 24, which lists the various note constants which will produce musical chords. A chord with a particular quality may be formed by playing its root, a 3rd Minor or Major, and other notes from the chord chart. For example, a C Major
chord is formed from C(/2), E(/2), and G(/2).
Fig. 24 CHORD SELECTION CHART
Page 47
5.4
5.4.1 RELATIVE CHANNEL VOLUME
VARIATION
The independently programmable amplitude control for each chan­nel allows up to 16 levels if using the processor controlled amplitude mode (bit 4 of registers 10, 11 or 12=0). In the case of a decaying or steady note, when a note is played or “fired”, a frequency may be set up in the coarse and fine tune registers and then an amplitude value placed in the respective register 10, 11 or 12. The value which is placed to play the tune can be an independent variable, allowing channels to play their respective melody lines with varying force.
5.4.2 DECAY
The main difference between a “piano” sound and an “organ” sound
is the speed with which the note loses volume. If all of the notes can be decayed at a uniform rate, the automatic envelope generator can be set to produce a decaying waveform. Each of the three channels can have the same decay constant but differing playing times tosimulate
the same instrument with differing note-strike times.
Sound
5.4.3 OTHER EFFECTS
The addition of variable noise to any or all of the channels can produce modification effects such “breathing” with a wind instru­ment. Or noise can be used alone to produce a drum rhythm. The fact that the noise dominant frequencies are variable allows “synthesizer”
type effects with simple processor interaction.
Other pleasing effects include vibrato and tremolo, the cyclical
variation of the frequency and volume. Because an intelligent
microprocessor is controlling the effect, they can be all keyed to the
tune itself or to other external stimuli.
A
Page 48
5.5
Applications
Fig. 25 ORGAN ENVELOPE GENERATION
While many applications of the PSG in music generation are apparent, for instance in the area of toys and games, other applica­tions are possible even in the area of high accuracy sophisticated musical instruments such as high-end electronic organs. With tone frequencies generated from another source to meet the exacting requirements of organ operation, the PSG can be used as a complex envelope generator. The PSG is also effective for generating bass notes and rhythms with percussion instruments, taking advantageof the PSG’s high accuracy in producing low frequency notes. The following paragraphs detail examples of these applications.
5.5.1 ORGAN ENVELOPE GENERATION
The envelope generation diagram shown in Fig. 25 illustrates how an AY-3-8910 can be configured to produce envelopes for organ voicing. All functions are controlled by a microcomputer.
The basis of this system consists of a master frequency generator with a string of dividers. This produces all frequencies for the keyboard. The microcomputer and the AY-3-8910 are actually used to replace the usual components of voicing filters that would ordinarily be used in an electronic organ.
The microcomputer shown is a Gl PIC 1650 controlled by inputsfrom
the keyboard keyer circuit and a control switch matrix. The keyer inputs octave and key closure information to develop the envelope amplitude and duration for the note to be played. The control switch matrix can be used to control sustain and add other special effects. The ROM shown connected to the AY-3-8910 is optional depending on the amount of data necessary for the microcomputer.
The system shown here may also consist of multiple AY-3-8910’s all controlled by a single microcomputer. It represents an economical solution to developing voicing control with a minimum of compo­nents.
Page 49
5.5
5.5.2 ORGAN RHYTHM GENERATION
Applications
The rhythm generation diagram (Fig. 26) illustrates a simplified version of how a microcomputer can be implemented with the AY-3­8910 to provide a percussion instrument section for an electronic
(cont.) organ.
The microcomputer used in this case could be a GI PIC 1650 which can be internally programmed to drive a series of AY-3-8910’s all hardwired to an I/O port of the PIC. Each AY-3-8910 provides a separate output envelope and frequency of the instrument it is to synthesize.
The Rhythm Switch Matrix is used to select any preprogrammed rhythm pattern and tempo from the PIC. The Instrument Select switches allow manual in/out selection of the 8910’s via the A8 and A9 address lines providing additional instrument sound variations. These switches are intended to be user-selected and mounted in a
convenient position on the instrument.
In addition, optional ROMs could be added to the PSG I/O ports, saving microcomputer ports, to provide extra rhythm length or number of patterns. These ROMs could also be replaced by EAROMs to provide user rhythm programming from a modified Rhythm Switch Matrix. The programmable rhythm feature could be used to add new or original user rhythms to update the instrument.
Fig. 26 ORGAN RHYTHM GENERATION
Page 50
6 SOUND EFFECTS GENERATION
One of the main uses of the PSG is to produce non-musical sound effects to accompany visual action or as a feature in itself. The following sections outline techniques and provide actual examples of some popular effects. All examples are based on a 1.78977MHz PSG
clock.
6.1
Many effects are possible using only the tone generation capability of
Tone Only
the PSG without adding noise and without using the PSG’s envelope generation capability. Examples of this type of effect would include
Effects
telephone tone frequencies (two distinct frequencies produced simultaneously) or the European Siren effect listed in Fig. 27 (two distinct frequencies sequentially produced).
Fig. 27 EUROPEAN SIREN SOUND EFFECT CHART
Page 51
6.2
Some of the more commonly required sounds require only the use of
Noise Only
noise and the envelope generator (or processor control of channel envelope if other channels are using the envelope generator).
Effects
Examples of this, which can be seen in Figs. 28 and 29, are gunshot and explosion. In both cases pure noise is used with a decaying envelope. In the examples shown the only changes are in the length of the envelope as modified by the coarse tune register and in the noise period. Note that a significantly lower explosion can be obtained by using all three channels operating with the same parameters.
Fig. 28 GUNSHOT SOUND EFFECT CHART
Octal
Register # Load Value
Explanatlon
Any not specified
000
R6
017
Set Noise period to mid-value.
R7
007
Enable Noise only on Channels A,B,C.
RlO
020
Rll
020
Select full amplitude range under direct
R12
020
control of Envelope Generator.
R14
020
Set Envelope period to 0.586 seconds.
R15
000
Select Envelope “decay”, one cycle only.
Fig. 29 EXPLOSION SOUND EFFECT CHART
Register #
Any not specified
R6
R7 R10 R11 R12 R14 R15
Octal
Load Value
Explanation
000 000
Set Noise period to max. value.
007
Enable Noise only, on Channels A,B,C. 020 020
Select full amplitude range under 020
direct control of Envelope Generator. 070
Set Envelope period to 2.05 seconds.
000
Select Envelope “decay”, one cycle only.
Page 52
7 ELECTRICAL SPECIFICATIONS
Page 53
6.4
Multi-Channel
Effects
Because of the independent architecture of the PSG, many rather complex effects are possible without burdening the processor. For example, the Wolf Whistle effect in Fig. 32 shows two channels in use to add constant breath hissing noise to the three concentrated frequency sweeps of the whistle. Once the noise is put on the channel, the processor only need be concerned with the frequency sweep operation.
Fig. 32
WOLF WHISTLE SOUND EFFECT CHART
Fig. 33
Page 54
7 ELECTRICAL SPECIFICATIONS
Page 55
Page 56
Loading...