TMP92CZ26A

92CZ26A-592

3.22.3 Operational Description

3.22.3.1 Melody generator
The Melody function generates signals of any frequency (4Hz-5461Hz) based on
low-speed clock (32.768KHz) and outputs the signa ls from th e MLDALM pin.
By connecting a loud speaker ou tside, Melody tone can easily sound.
(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 a re setting example and calculation of melody outp ut frequency.
(Formula for calcul ating of melody waveform frequency)
@fs = 32.768 [kHz]
Melody output waveform fMLD[Hz] = 32768/ (2 × N + 4)
Setting value for melody N = (16384/ fMLD) 2
(Note: N = 1~4095 (001H~FFFH), 0 is not acceptable)
(Example program)
In case of outputting “A” musical scale (440Hz)
LD (MELALMC), −−XXXXX1B ; Select melody waveform
LD (MELFL), 23H ; N = 16384/440 2 = 35.2 = 023H
LD (MELFH), 80H ; Start to generate waveform
(Refer: 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