Rev. 1.10
96
November 26, 2019
Rev. 1.10
97
November 26, 2019
HT68FB240
USB Low Speed Flash MCU
PWM Output Control
On the device, the PWM outputs are pin-shared with pins PC4, PC5 and P
C6
. To operate as PWM
outputs and not as I/O pins, the correct PWM configuration options must be selected. A "0" must
also be written to the corresponding bits in the I/O port control register P
C
C to ensure that the
required 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 PWM register, writing a "1" to
the corresponding bit in the P
C
output data register will enable the PWM data to appear on the pin.
Writing a "0" to the corresponding bit in the P
C
output data register will disable The PWM output
function and force the output low. In this way, the Port
C
data output register can be used as an on/
off control for the PWM function. Note that if the configuration options have selected the PWM
function, but a "1" has been written to its corresponding bit in the P
C
C 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 PWM outputs are setup and controlled. Before use
the corresponding PWM output configuration options must first be selected.
mov a,64h ;
setup PWM value of 100 decimal which is 64H
mov pwm0,a
set pwmc.7 ;
select the 7+1 PWM mode
set pwmc.0 ;
setup PWM0 shared with P
C4
clr pcc.4 ;
setup pin P
C4 as an output
set pc.4 ;
P
C.4
=1; enable the PWM output
:
:
clr pc.4 ;
disable the PWM output _ P
C4 will remain low