Sound Generation Logic (SGL)
MPC5606S Microcontroller Reference Manual, Rev. 7
Freescale Semiconductor 1117
 
If a continuous sound is selected, then set SOUND_DURATION = 0, and 
select SOUND_CTRL = 5 (single duration sound). If 
SOUND_DURATION is previously configured, then the sound will stop 
when the value in SOUND_DURATION counts down to 0. If required, it is 
possible to set SOUND_CONTROL
 = 0 once the sound has stopped.
If a non-continuous sound is selected, then wait until the sound stops and 
then set SOUND_CTRL =  0. 
It is advisable to choose the values for HIGH_PERIOD, LOW_PERIOD and SOUND_DURATION in 
such a way that SOUND_DURATION is an integral multiple of the sum of LOW_PERIOD and 
HIGH_PERIOD.
The HIGH_PERIOD and LOW_PERIOD registers can also be used as a volume control for monophonic 
sound when SOUND_CTRL[2] is 1.
In case where monophonic sound is to be generated, the software configures the MODE_SEL register 
through IPS interface such that the set of 4 bits (CH1_SEL[0:3]) can be used to select output from one of 
the PWM channels being used for sound generation. This output will be the one having variable duty cycle 
and fixed frequency.
Similarly, the 4 bits configured by the software comprise the signal ch2_sel[0:3], thus leading to selection 
of output from the second PWM channel being used for sound generation. This output from second 
channel will be the one having fixed duty cycle and variable frequency.
Simultaneously, mono/poly_b is configured such that for monophonic sound generation its value will be 
one, and hence the output from the and gate will be selected i.e. the ANDing of signals from MuxA 
(variable duty cycle, fixed frequency) and MuxB (fixed duty cycle, variable frequency) will produce 
monophonic sound.
In case where polyphonic sound is to be generated, the software configures the MODE_SEL register 
through the IPS interface such that the set of 4 bits (CH1_SEL[0:3]) can be used to select output from the 
PWM channel being used for sound generation.
Simultaneously, mono/poly_b is configured such that for polyphonic sound generation its value will be 
zero, and hence the output corresponding to the signal producing polyphonic sound will be selected.
The suggested sequence of events for sound generation controlled by SOUND_CTRL[0:2] is:
1. Initially SOUND_CTRL[0:2] is 3’b000.
2. Program the SOUND_DURATION/ HIGH_PERIOD/LOW_PERIOD registers’ values, 
depending on the mode of sound generation which is desired.
3. Program the SOUND_CTRL[0:2] bits to the new value depending on the mode desired.
4. Edge detector detects the change on SOUND_CTRL[0:2] bits.
5. On the next clock edge after the edge detection, the sound generation starts.
6. In cases where the sound duration depends on the value in SOUND_DURATION register, the 
sound generation stops when SOUND_DURATION counter reaches zero. An interrupt is raised as 
soon as the SOUND_DURATION counter reaches zero. In these cases, the ISR changes the 
SOUND_CTRL[0:2] to 3’b000 from the present value.