852
Chapter 24
Sound Generator (SG)
Preliminary User’s Manual U17566EE1V2UM00
(2)
PWM calculations
PWM frequency
The PWM frequency is generated by the counter SG0FL. It can be calculated
as:
f
PWM
= f
SG0CLK
/ (([SG0FL buffer] + 1)
where:
f
SG0CLK
= frequency of the SG0 input clock
[SG0FL buffer] = contents of the SG0FL buffer
Duty cycle
The duty cycle of the PWM signal is calculated as follows:
• If [SG0PWM buffer] > [SG0FL buffer]:
Duty cycle = 100 %
• If 0
≤
[SG0PWM buffer]
≤
[SG0FL buffer]:
Duty cycle = [SG0PWM buffer] / ([SG0FL buffer] + 1)
where:
[SG0PWM buffer] = contents of SG0PWM buffer
[SG0FL buffer] = contents of SG0FL buffer
Example
If [SG0FL] is set to 240 (00F0
H
), the following table applies:
The table shows, how the contents of register SG0FL affects the achievable
volume resolution.
Table 24-4
Duty cycle calculation example
[SG0PWM]
Calculation
Duty cycle [%]
01FF
H
100
...
100
00F1
H
241 / 241
100
00F0
H
240 / 241
99.6
00EF
H
239 / 241
99.2
...
...
...
0001
H
1
/
241
0.41
0000
H
0
/
241
0
electronic components distributor