HT82A520R HOLTEK [Holtek Semiconductor Inc], HT82A520R Datasheet - Page 32

no-image

HT82A520R

Manufacturer Part Number
HT82A520R
Description
Full Speed USB 8-Bit OTP MCU with SPI
Manufacturer
HOLTEK [Holtek Semiconductor Inc]
Datasheet
8+4 PWM Mode Modulation
Each full PWM cycle, as it is 12-bits wide, has 4096 clock
periods. However, in the 8+4 PWM mode, each PWM cy-
cle is subdivided into sixteen individual sub-cycles known
as modulation cycle 0 ~ modulation cycle 15, denoted as
tains 256 clock cycles. In this mode, a modulation fre-
quency increase of sixteen is achieved. The 12-bit PWM
register value, which represents the overall duty cycle of
the PWM waveform, is divided into two groups. The first
group which consists of bit4~bit11 is denoted here as the
DC value. The second group which consists of bit0~bit3
is known as the AC value. In the 8+4 PWM mode, the
duty cycle value of each of the two modulation sub-cycles
is shown in the following table.
The accompanying diagram illustrates the waveforms
associated with the 8+4 mode of PWM operation. It is
important to note how the single PWM cycle is subdi-
vided into 16 individual modulation cycles, numbered
0~15 and how the AC value is related to the PWM value.
PWM Programming Example
The following sample program shows how the output is setup and controlled.
mov a,64h
mov pwm0h,a
clr pwm0l
clr pac.4
set pwm0en
set pa.4
clr pa.4
Rev.1.00
i in the table. Each one of these sixteen sub-cycles con-
:
:
Modulation cycle i
Parameter
:
:
(i=0~15)
8+4 Mode Modulation Cycle Values
; setup PWM0 value to 1600 decimal which is 640H
; setup PWM0H register value
; setup PWM0L register value
; setup pin PA4 as an output
; set the PWM0 enable bit
; Enable the PWM0 output
; PWM0 output disabled
AC (0~15)
i AC
i AC
DC (Duty Cycle)
DC+1
256
256
DC
PA4 will remain low
32
PWM Output Control
The three outputs, PWM0, PWM1, and PWM2 are
shared with pins PA4, PA5 and PB0. To operate as a
PWM output and not as an I/O pin, bit 0 of the relevant
PWM low byte register bit must be set high. A zero must
also be written to the corresponding bit in the PAC and
PBC port control register, to ensure that the PWM0 out-
put pin is setup as an output. After these two initial steps
have been carried out, and of course after the required
PWM 12-bit value has been written into the PWM regis-
ter pair register, setting the corresponding bit in the PA
and PB data register high will enable the PWM data to
appear on the pin. Writing a zero to the bit will disable
the PWM output function and force the output low. In this
way, the Port A and Port B data output register bits, can
also be used as an on/off control for the PWM function.
Note that if the enable bit in the PWM register is set high
to enable the PWM function, but if the corresponding bit
in the PAC and PBC control register is high to configure
the pin as an input, then the pin can still function as a
normal input line, with pull-high resistor selections.
HT82A520R/HT82A620R
October 23, 2009

Related parts for HT82A520R