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