HC12 - Two Choices of Clock for PWM
- 1.
- PCLKx = 0:
- 2.
- PCLKx = 1:
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.
- Try PCLKx = 0 and PWPERx = 255
Not possible
Try PWPERx = 199
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
1999-03-09