HC12 - Two Choices of Clock for PWM
- 1.
- PCLKx = 0 (Clock A or B):
- 2.
- PCLKx = 1 (Clock S0 or S1):
N = PCKA 2:0 for PWM 1 and 0,
N = PCKB 2:0 for PWM 3 and 2.
M = PWSCAL0 7:0 for PWM 1 and 0,
M = PWSCAL1 7:0 for PWM 3 and 2.
Normally want PWPERx = 200 -> 255.
Example: Want 5 kHz PWM - Per
= 200 s = 1,600 P clock
cycles..
- 1.
- Try PCLKx = 0 and PWPERx = 255
Not possible.
Try 2N = 8, N = 3
Exactly 5 kHz, get 1 part in 200 accuracy
- 2.
- Try PCLKx = 1 and PWPERx = 255
Not possible. Use a slightly different frequency - let
This gives
for a 5.2 kHz frequency
Bill Rison
2000-03-01