853
Sound Generator (SG)
Chapter 24
Preliminary User’s Manual U17566EE1V2UM00
24.4 Sound Generator Application Hints
This section provides supplementary programming information.
24.4.1
Initialization
To enable the Sound Generator, set SG0CTL.PWR to 1. This connects the
SG0 to the clock SG0CLK.
Check bit SG0CTL.OS.
When SG0CTL.OS is 0, the signal at pin SGO is a symmetrical square
waveform with the frequency f
tone
. When SG0CTL.OS is 1, the signal at pin
SGO is composed of the tone signal and PWM pulses.
The frequency data registers SG0FL and SG0FH provide the buffer values for
the counters. The combined value represents the frequency of the tone.
24.4.2
Start and stop sound
The sound is started by writing a non-zero value to the volume register
SG0PWM.
Before starting the sound, all other register settings must be made.
The sound is stopped by writing 0000
H
to the volume register SG0PWM. The
sound is stopped regardless of the current value of amplitude output or
frequency output. Thus, the sound can be stopped quickly, even if a very low
sound frequency is chosen.
24.4.3
Change sound volume
The sound volume is changed by writing a new value to register SG0PWM.
The new volume takes effect with the next edge of the tone pulse (rising or
falling).
24.4.4
Generate special sounds
To generate special sounds (like blinker clicks etc.), frequency and volume can
be changed simultaneously.
To change the frequency of a sound that has already started
:
1. Write to frequency register SG0FL in 32-bit mode (or to SG0FL and
SG0FH separately in 16-bit mode).
2. Write to volume register SG0PWM.
electronic components distributor