Making It Easy With Pitch - FIGnition FUZE Hardware Reference Manual

Table of Contents

Advertisement

Prescalar Value
5
This is all that audio generation involves. The very first thing is to turn the audio on (by
making port D6 an output).
: aud
64 191 42 >port> ( make PortD6 an output by setting bit 6)
drop
;
Creating the command
Then we calculate the prescalar and match_value. Then first we turn off the timer (by set-
ting the prescalar to 0); configure the timer as described above; set the match_value and
prescalar value and finally setting the prescalar value starts the timer, which generates a
note. This can be wrapped up in a
FUZE, and re-listed here:
Command(s)
Code
prescalar freq
: beep
beep
;
To use beep you'd type, for example
near G on a piano. You can stop a beep using
4.2.3 Making It Easy With Pitch> .
To make tuneful music you need a fine control of the pitch. It's possible to set a wide range
of pitches using just different match_values, but as the match_values get lower, the jumps
in pitch get increasingly large. For example, if the match_value was 2 and you change it to
1, then the pitch will double, a jump of one octave! But if the match_value was 255 and
you change it to 254 then the pitch will jump by a small fraction of a semitone.
Prescalar Divider
20MHz/1024
and then typing
aud
beep
0 69 ic!
0 110 ic!
66 68 ic!
71 ic!
7 and 69 ic!
4 100 beep <exe>
match_value=1
9.77KHz
will do this.
aud <exe>
command, which is bundled with FIGnition in-
Explanation
beep
expects to be provided with the
prescalar and frequency.
First disable the timer.
Disable any timer interrupts.
Set Counter/Timer mode so that the
output toggles every time the timer
reaches the match_value.
Store the match_value at address 71
which is an AVR register called
OCR0A
Store the prescalar (masked into the
range 0..7) at address 69, which is
an AVR register called TCCR0B
Finish the command.
0 0 beep <exe>
match_value=255
38.3Hz
, which will give a frequency
.

Advertisement

Table of Contents
loading

Table of Contents