842
Chapter 24
Sound Generator (SG)
Preliminary User’s Manual U17566EE1V2UM00
24.1.1
Description
The following figure provides a functional block diagram of the Sound
Generator.
Figure 24-1
Sound Generator block diagram
The Sound Generator's input clock SG0CLK is the 16 MHz clock PCLK0.
Tone generator
The tone generator consists of two up-counters with compare registers. The
values written to the frequency registers are automatically copied to compare
buffers. The counters are reset to zero when their values match the contents of
the associated compare buffers.
The 9-bit counter SG0FL generates a clock with a frequency between 32 KHz
and 64 KHz. This clock constitutes the PWM frequency.
It is also the input of the second 6-bit counter SG0FH. The resulting tone signal
behind the by-two-divider has a frequency between 245 Hz and 6 KHz and a
50 % duty cycle.
PWM
The PWM modulates the duty cycle according to the desired volume. It is
controlled by the volume register SG0PWM. The value written to this register is
automatically copied to the associated volume compare buffer.
The PWM continually compares the value of the counter SG0FL with the
contents of its volume compare buffer.
The RS flipflop of the PWM is set by the pulses generated by the counter
SG0FL. It is reset when the SG0FL counter value matches the contents of the
volume buffer. Thus, the PWM output signal can have a duty cycle between
0 % (null volume) and 100 % (maximum volume).
The PWM frequency is above 32 KHz and hence outside the audible range.
Outputs
The Sound Generator is connected to the pins SGO and SGOA. By default, pin
SGO provides the tone signal SG0OF and pin SGOA the PWM signal SG0OA
that holds the volume (“amplitude”) information.
If bit SG0CTL.OS is set, pin SGO provides the composite signal SG0O that
can directly control a speaker circuit.
&
f
PWM
(min. 32 kHz)
f
Tone
(245 Hz to
6 kHz)
SG0PWM
volume compare buffer
SG0A
SGO
SG0FH
tone compare buffer
9-bit S0GFH
Tone
6-bit S0GFH
tone counter
SG0FL
frequency compare buffer
9-bit S0GFL
frequency counter
Clear
f
PWM
(32 to 64 kHz)
S
R
&
PWM
Tone
/2
Match
Load
Match
Load
Clear
Load
Match
RS-FF
SG0CTL.PWR
0
1
SG0CTL.OS
0
1
CPU write to
SG0PWM
SG0CLK =
PCLK0
(16MHz)
SG0FL
frequency low register
SG0FH
frequency high register
SG0PWM
volume register
= 0?
Reset
&
SG0OF
SG0
SG0OA
2 x f
Tone
(490 Hz to
12 kHz)
Y
f
PWM
(32 to 64 kHz)
electronic components distributor