
Rev. 1.40
76
March 29, 2019
Rev. 1.40
77
March 29, 2019
HT45F23A/HT45F24A
TinyPower
TM
Flash MCU with OPA & Comparators
HT45F23A/HT45F24A
TinyPower
TM
Flash MCU with OPA & Comparators
PWM Output Control
The PWM outputs are pin-shared with the I/O pins PC5 and PC6. To operate as a PWM output
and not as an I/O pin, the correct bits must be set in the BPCTL register. A high value must be
written to the PWM0EN or PWM1EN to select the corresponding PWM. A zero value must also be
written to the corresponding bit in the I/O port control register PCC.5 and PCC.6 to ensure that the
corresponding PWM output pin is setup as an output. After these two initial steps have been carried
out, and of course after the required PWM value has been written into the PWMn register, writing a
high value to the corresponding bit in the output data register PC.5 and PC.6 will enable the PWM
data to appear on the pin. Writing a zero value will disable the PWM output function and force the
output low. In this way, the Port data output registers can be used as an on/off control for the PWM
function. Note that if the BPCTL register has selected the PWM function, but a high value has been
written to its corresponding bit in the PCC control register to configure the pin as an input, then the
pin can still function as a normal input line, with pull-high resistor options.
PWM Programming Example
The following sample program shows how the PWM0 output is setup and controlled.
mov a,64h ; setup PWM value of decimal 100
mov pwm0,a
clr bpctl.7 ; select the 7+1 PWM mode
set bpctl.5 ; select PWM0
clr pcc.5 ; setup pin PC5
set pc.5 ; enable the PWM output
:
:
clr pc.5 ; disable the PWM output pin,PC5 forced low