Using Timer 0 To Generate Audio - FIGnition FUZE Hardware Reference Manual

Table of Contents

Advertisement

4.2.2 Using Timer 0 To Generate Audio

Audio works by making use of a timer circuit inside the FIGnition's processor, the AVR. The
timer logic is fairly simple (at least it is the way the audio uses it). There is an internal 8-bit
counter, which increments every CPU clock cycle divided by either 1, 8, 64, 256 or 1024
(which is held in a 3-bit internal variable called the prescalar). There's also a match_value
which is just another internal 8-bit variable, called an output compare register. Finally, we
can configure the timer so that whenever its value reaches the match_value, it will switch
the voltage on port D6 (pin 12) from 5v to 0v or back to 5v and reset the timer.
If you put this together it means port D can be made to oscillate at:
And it turns out we can pick match_values and prescalars which give sensible audio fre-
quencies:
Prescalar Value
1
2
3
4
2*match_value*prescalar
Prescalar Divider
20MHz/1
20MHz/8
20MHz/64
20MHz/256
Fig 4.7
20000000
match_value=1
10MHz
1.25MHz
156KHz
39.1KHz
match_value=255
39.2KHz
4.9KHz
612.7Hz
153.2Hz

Advertisement

Table of Contents
loading

Table of Contents