22.09.2015 Views

of Microprocessors

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

Musical-Applications-of-Microprocessors-2ed-Chamberlin-H-1987

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

760 MUSICAL ApPLICATIONS OF MICROPROCESSORS<br />

Obviously, the free-running type is much more suitable as a programmable<br />

oscillator because a frequency control word can be written into the<br />

interval register once and the timer will then generate pulses at that<br />

frequency automatically without program intervention. Generally, the microsecond-wide<br />

pulses produced must be shaped before they can effectively<br />

operate a speaker. One possibility is to use the pulse to discharge a capacitor<br />

that is being constantly charged through a resistor or current source. This<br />

produces a sawtooth wave that' is useful over a range <strong>of</strong> two to three octaves.<br />

Another possibility is to have the pulse trigger a single shot to produce a<br />

much wider pulse and thus a rectangular waveform. Sophisticated multichannel<br />

timer chips such as the Intel 8253 can be programmed so that one timer<br />

determines the frequency in free-running mode and triggers another timer in<br />

single-shot mo.de, thus producing a programmable duty cycle. The Motorola<br />

6840 produces the same effect by splitting its 16-bit timer register into two<br />

8-bir halves, one <strong>of</strong> which determines the waveform high time and the other<br />

determines the low time. Of course, the pulse ourput can also toggle a flipflop<br />

for a square wave, a function built into some timer ICs.<br />

One particular peripheral interface chip that has been used extensively<br />

for sound generation in low-cost personal computers is the 6522 "versatile<br />

interface adapter" (VIA). This remarkable IC has two full 8-bit I/O ports,<br />

two timers, and a multimode 8-bit shift register. In a typical computer, the<br />

ports are used to interface to a printer and control internal functions, while<br />

the timers and shift register are either not used or are connected to a small<br />

amplifier and internal speaker. Timer 1 is a standard 16-bit unit that can<br />

operate in free-running mode and produce a pulse or half-frequency squarewave<br />

output. The other timer is more interesting, however, because it can<br />

operate in conjunction with the shift register. Although its counter is also 16<br />

bits, the interval register is only 8 bits, which limits frequency resolution<br />

somewhat. In one <strong>of</strong> its operating modes, the internal 8-bit shift register is<br />

rotated one position on each Timer 2 timeout. By writing different bit<br />

patterns into the shift register, different eight-segment waveforms can be<br />

produced on the shift register output pin for a number <strong>of</strong> different timbres (it<br />

is instructive to determine how many audibly different patterns there are).<br />

One can even set the shift register to shift at its maximum rate and then use<br />

different bit patterns to simulate a pulse-width modulated nine-level D-to-A<br />

converter for producing somewhat smoother waveforms. Also, since the two<br />

timers are independent, two simultaneous tones are readily produced. In all,<br />

the 6522 provides quite a lot <strong>of</strong> sound-generation function <strong>of</strong>ten for little or<br />

no added cost.<br />

IS<br />

Timed Program Loops<br />

Of course, the classic method <strong>of</strong> producing simple sounds by computer<br />

the timed program loop. It is, in fact, so simple and fundamental (and

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!