TMP91C824
91C824-216
2008-02-20
3.14.3 Operational
Description
(1) Melody generator
The melody function generates signals of any frequency (4 Hz to 5461 Hz) based on
low-speed clock (32.768 kHz) and outputs the signals from the MLDALM pin.
By connecting a loud speaker outside, melody tone can sound easily.
(Operation)
At first, MELALMC<MELALM> have to be set as 1 in order to select melody
waveform as output waveform from MLDALM. Then melody output frequency has to
be set to 12-bit register MELFH, MELFL.
Followings are setting example and calculation of melody output frequency.
(Formula for calculating of melody waveform frequency)
at
fs
=
32.768 [kHz]
melody output waveform
f
MLD
[Hz]
=
32768/(2
×
N
+
4)
setting value for melody
N
=
(16384/f
MLD
) – 2
(notice:
N
=
1 to 4095(001H to FFFH), 0 is not acceptable)
(Example program)
In case of outputting La musical scale (440 Hz)
LD
(MELALMC), ---XXXX1B ; select melody waveform
LD
(MELFL), 23H
; N
=
16384/440 – 2
=
35.2
=
023H
LD
(MELFH), 80H
; start to generate waveform
(Refer to Basic musical scale setting table)
Scale
Frequency [Hz]
Register Value: N
C 264
03CH
D 297
035H
E 330
030H
F 352
02DH
G 396
027H
A 440
023H
B 495
01FH
C 528
01DH