HT45F12
8-Bit Flash MCU with Op Amps & Comparators
Programming Considerations
Withinꢀtheꢀuserꢀprogram,ꢀoneꢀofꢀtheꢀfirstꢀthingsꢀtoꢀconsiderꢀisꢀportꢀinitialisation.ꢀAfterꢀaꢀreset,ꢀallꢀofꢀ
theꢀI/Oꢀdataꢀandꢀportꢀcontrolꢀregistersꢀwillꢀbeꢀsetꢀhigh.ꢀThisꢀmeansꢀthatꢀallꢀI/Oꢀpinsꢀwillꢀdefaultꢀtoꢀ
anꢀinputꢀstate,ꢀtheꢀlevelꢀofꢀwhichꢀdependsꢀonꢀtheꢀotherꢀconnectedꢀcircuitryꢀandꢀwhetherꢀpull-highꢀ
selectionsꢀhaveꢀbeenꢀchosen.ꢀIfꢀtheꢀportꢀcontrolꢀregisters,ꢀPAC~PCC,ꢀareꢀthenꢀprogrammedꢀtoꢀsetupꢀ
someꢀpinsꢀasꢀoutputs,ꢀtheseꢀoutputꢀpinsꢀwillꢀhaveꢀanꢀinitialꢀhighꢀoutputꢀvalueꢀunlessꢀtheꢀassociatedꢀ
portꢀdataꢀregisters,ꢀPA~PC,ꢀareꢀfirstꢀprogrammed.ꢀSelectingꢀwhichꢀpinsꢀareꢀinputsꢀandꢀwhichꢀareꢀ
outputsꢀcanꢀbeꢀachievedꢀbyte-wideꢀbyꢀloadingꢀtheꢀcorrectꢀvaluesꢀintoꢀtheꢀappropriateꢀportꢀcontrolꢀ
registerꢀorꢀbyꢀprogrammingꢀindividualꢀbitsꢀinꢀtheꢀportꢀcontrolꢀregisterꢀusingꢀtheꢀ“SETꢀ[m].i”ꢀandꢀ
“CLRꢀ[m].i”ꢀinstructions.ꢀNoteꢀthatꢀwhenꢀusingꢀtheseꢀbitꢀcontrolꢀinstructions,ꢀaꢀread-modify-writeꢀ
operationꢀtakesꢀplace.ꢀTheꢀmicrocontrollerꢀmustꢀfirstꢀreadꢀinꢀtheꢀdataꢀonꢀtheꢀentireꢀport,ꢀmodifyꢀitꢀtoꢀ
theꢀrequiredꢀnewꢀbitꢀvaluesꢀandꢀthenꢀrewriteꢀthisꢀdataꢀbackꢀtoꢀtheꢀoutputꢀports.
T
1
T
2
T
3
T
4
T
1
T
2
T
3
T
4
S
y
e
s
t
m
C
l
c
o
k
P
r
o
t
D
a
a
t
R
e
a
f
o
d
r
m
P
o
t
r
W
i
r
e
t
t
o
o
t
r
P
Read Modify Write Timing
PortꢀAꢀhasꢀtheꢀadditionalꢀcapabilityꢀofꢀprovidingꢀwake-upꢀfunctions.ꢀWhenꢀtheꢀdeviceꢀisꢀinꢀtheꢀ
SLEEPꢀorꢀIDLEꢀMode,ꢀvariousꢀmethodsꢀareꢀavailableꢀtoꢀwakeꢀtheꢀdeviceꢀup.ꢀOneꢀofꢀtheseꢀisꢀaꢀhighꢀ
toꢀlowꢀtransitionꢀofꢀanyꢀofꢀtheꢀPortꢀAꢀpins.ꢀSingleꢀorꢀmultipleꢀpinsꢀonꢀPortꢀAꢀcanꢀbeꢀsetupꢀtoꢀhaveꢀthisꢀ
function.ꢀInꢀaddition,ꢀtheꢀPortꢀBꢀpinsꢀalsoꢀprovideꢀOpenꢀDrainꢀI/Oꢀstructureꢀoptionsꢀwhichꢀcanꢀbeꢀ
controlledꢀbyꢀtheꢀspecificꢀregister.
Timer/Event Counter
Theꢀprovisionꢀofꢀtimersꢀformꢀanꢀimportantꢀpartꢀofꢀanyꢀmicrocontroller,ꢀgivingꢀtheꢀdesignerꢀaꢀmeansꢀ
ofꢀcarryingꢀoutꢀtimeꢀrelatedꢀfunctions.ꢀTheꢀdeviceꢀcontainsꢀaꢀsigleꢀcount-upꢀtimerꢀofꢀ8-bitꢀcapacity.ꢀ
Asꢀtheꢀtimerꢀhasꢀthreeꢀdifferentꢀoperatingꢀmodes,ꢀitꢀcanꢀbeꢀconfiguredꢀtoꢀoperateꢀasꢀaꢀgeneralꢀtimer,ꢀ
anꢀexternalꢀeventꢀcounterꢀorꢀasꢀaꢀpulseꢀwidthꢀcaptureꢀdevice.ꢀTheꢀprovisionꢀofꢀanꢀinternalꢀprescalerꢀ
toꢀtheꢀclockꢀcircuitryꢀonꢀgivingꢀaddedꢀrangeꢀtoꢀtheꢀtimer.
ThereꢀareꢀtwoꢀtypesꢀofꢀregistersꢀrelatedꢀtoꢀtheꢀTimer/EventꢀCounter.ꢀTheꢀfirstꢀisꢀtheꢀregistersꢀthatꢀ
containꢀtheꢀactualꢀvalueꢀofꢀtheꢀTimer/EventꢀCounterꢀandꢀintoꢀwhichꢀanꢀinitialꢀvalueꢀcanꢀbeꢀpreloaded.ꢀ
ReadingꢀfromꢀtheseꢀregistersꢀretrievesꢀtheꢀcontentsꢀofꢀtheꢀTimer/EventꢀCounter.ꢀTheꢀsecondꢀtypeꢀ
ofꢀassociatedꢀregisterꢀisꢀtheꢀTimerꢀControlꢀRegisterꢀwhichꢀdefinesꢀtheꢀtimerꢀoptionsꢀandꢀdeterminesꢀ
howꢀtheꢀTimer/EventꢀCounterꢀisꢀtoꢀbeꢀused.ꢀTheꢀTimer/EventꢀCounterꢀcanꢀhaveꢀitsꢀclockꢀconfiguredꢀ
toꢀcomeꢀfromꢀanꢀinternalꢀclockꢀsource.ꢀInꢀaddition,ꢀitsꢀclockꢀsourceꢀcanꢀalsoꢀbeꢀconfiguredꢀtoꢀcomeꢀ
fromꢀanꢀexternalꢀtimerꢀpin.
D
t
a
a
B
u
s
T
M
1
M
T
0
T
S
P
2
C
T
~
S
P
0
C
(
/
1
~
1
/
1
2
1
)
8
R
l
o
e
a
d
P
e
r
o
l
a
R
e
d
i
g
t
s
r
e
S
f
S
Y
7
s
-
a
t
g
e
P
e
r
c
s
l
a
r
e
T
m
i
r
e
E
/
e
v
n
C
o
t
u
t
r
n
e
M
o
d
C
o
e
t
n
o
r
l
F
l
e
i
t
r
T
M
R
M
U
F
l
e
i
t
r
O
n
O
/
f
f
T
E
X
T
m
i
r
e
E
/
e
v
n
t
O
e
v
f
r
o
l
w
C
n
o
i
f
u
g
r
i
a
n
o
t
o
t
o
i
p
n
C
u
o
t
n
r
e
T
N
O
t
o
n
t
r
I
e
p
u
r
C
m
o
p
a
a
r
t
o
1
r
o
t
u
u
p
t
8
B
-
t
T
i
m
i
r
e
E
/
e
v
t
n
C
u
o
n
t
e
r
T
M
0
,
M
T
1
¸
2
P
D
F
8-bit Timer/Event Counter Structure
2
,
.
2
,
.
ꢀ
2
)
ꢁ
=
#
,
=
J
Note:ꢀTheꢀoutputꢀisꢀcontrolledꢀbyꢀPA5ꢀdata.
Rev. 0.00
5ꢅ
�eꢀteꢁꢂeꢃ ꢄꢅꢆ ꢄ01ꢄ