SN8P2624
8-Bit Micro-Controller
SONiX TECHNOLOGY CO., LTD
Page 84
Version 0.3
8.4.3 PWM Duty with TCxR Changing
In PWM mode, the system will compare TC1C and TC1R all the time. When TC1C<TC1R, the PWM will output logic
“High”, when TC1C
≧
TC1R, the PWM will output logic “Low”. If TC1C is changed in certain period, the PWM duty will
change in next PWM period. If TC1R is fixed all the time, the PWM waveform is also the same.
TC1C overflow
and TC1IRQ set
TC1C = TC1R
0xFF
TC1C Value
0x00
PWM1 Output
1
2
3
4
5
6
7
Period
Above diagram is shown the waveform with fixed TC1R. In every TC1C overflow PWM output “High, when TC1C
≧
TC1R PWM output ”Low”. If TC1R is changing in the program processing, the PWM waveform will became as following
diagram.
1
1st PWM
2
Update PWM Duty
3
2nd PWM
4
Update PWM Duty
0xFF
TC1C Value
0x00
PWM1 Output
Period
5
3th PWM
TC1C overflow
and TC1IRQ set
Old TC1R
Old TC1R
New TC1R
New TC1R
Update New TC1R!
Old TC1R < TC1C < New TC1R
Update New TC1R!
New TC1R < TC1C < Old TC1R
TC1C > = TC1R
PWM High > Low
TC1C < TC1R
PWM Low > High
In period 2 and period 4, new Duty (TC1R) is set. TC1 is double buffer design. The PWM still keeps the same duty in
period 2 and period 4, and the new duty is changed in next period. By the way, system can avoid the PWM not
changing or H/L changing twice in the same cycle and will prevent the unexpected or error operation.