HT45R37
PWM Programming Example
The following sample program shows how the PWM output is setup and controlled.
mov a,64h
mov pwm0h,a
clr pwm0l
clr pdc.0
set pwm0en
set pd.0
; setup PWM0 value to 1600 decimal which is 640H
; setup PWM0H register value
; setup PWM0L register value
; setup pin PD0 as an output
; set the PWM0 enable bit
; Enable the PWM0 output
:
:
:
:
clr pd.0
; PWM0 output disabled - PD0 will remain low
f
S
Y
S
[
[
[
P
P
P
W
W
W
M
M
M
]
]
]
=
=
=
1
1
1
6
6
6
0
0
0
0
1
2
P
P
P
W
W
W
M
M
M
1
1
1
0
0
0
0
1
1
/
/
/
2
2
2
5
5
5
6
6
6
1
1
1
0
0
0
0
0
1
/
/
/
2
2
2
5
5
5
6
6
6
1
1
1
0
0
0
0
0
0
/
/
/
2
2
2
5
5
5
6
6
6
1
1
1
0
0
0
0
0
0
/
/
/
2
2
2
5
5
5
6
6
6
1
1
1
0
0
0
0
1
1
/
/
/
2
2
2
5
5
5
6
6
6
[
P
W
M
]
=
1
6
1
5
P
W
M
1
0
1
/
2
5
6
1
0
1
/
2
5
6
1
0
1
/
2
5
6
1
0
0
/
2
5
6
1
0
1
/
2
5
6
P
W
M
m
o
d
u
l
a
S
t
Y
i
S
o
n
p
e
r
i
o
d
:
2
5
6
/
f
M
o
d
u
l
a
t
i
o
n
M
c
o
y
d
c
u
l
l
e
a
t
0
i
o
n
M
c
o
y
d
c
u
l
l
e
a
t
1
i
o
n
M
c
o
y
d
c
u
l
l
e
a
t
2
i
o
n
M
c
o
y
d
c
u
l
l
e
a
t
1
i
5
o
P
W
M
c
y
c
S
Y
l
S
e
:
4
0
9
6
/
f
8+4 PWM Mode
P
W
M
0
H
~
P
W
M
1
H
P
W
M
0
L
~
P
W
M
1
L
H
i
g
h
B
y
t
e
R
e
g
i
s
t
e
r
s
L
o
w
B
y
t
e
R
e
g
i
s
t
e
r
s
b
7
b
0
b
7
b
0
1
1
1
0
9
8
7
6
5
4
3
2
1
0
E
N
P
W
M
R
e
g
i
s
t
e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