Next: About this document ...
Using the HC12 PWM
- Choose 8-bit mode (PWCLK 7:6 = 00)
- Choose left-aligned (PWCTL 3 = 0)
- Choose polarity = 1 (PPOL 3:0 = 1111)
- Select clock mode in PWPOL: PCLKx = 0 for ,
PCLKx = 1 for
,
- Select in PWCLK register: PCKA 2:0 for channels 1, 0;
PCKB 2:0 for channels 3, 2.
- If PCLKx = 1, select : PWSCAL0 7:0 = for
channels 1, 0; PWSCAL1 7:0 = for channels 3, 2.
- Select PWPERx, normally between 200 and 255.
- Enable desired PWM channels: PWEN 3:0.
- Select PWDTYx, normally between 0 and PWPERx. Then
Change duty cycle to control speed of motor or intensity of light, etc.
- For 0% duty cycle, choose PWDTYx = 0xFF.
Bill Rison
2001-03-05