HT45F23A/HT45F24A
TinyPower
Flash MCU with OPA & Comparators
TM
A / D C o n v e r s i o n
R e s u l t
A/D Programming Example
The following two programming examples illustrate how to setup and implement an A/D
conversion. In the first example, the method of polling the EOCB bit in the ADCR register is used to
detect when the conversion cycle is complete, whereas in the second example, the A/D interrupt is
used to determine when the conversion is complete.
Example: using an EOCB polling method to detect the end of conversion
clr EADI
mov a,01H
mov ACSR,a
mov a,FFh
mov ADPCR,a
mov a,00h
mov ADCR,a
:
start_conversion:
clr START
set START
clr START
polling_EOC:
sz
EOCB
jmp polling_EOC
mov a,ADRL
mov ADRL_buffer,a
mov a,ADRH
mov ADRH_buffer,a
:
:
jmp start_conversion ; start next a/d conversion
Rev. 1.40
F F F H
F F E H
F F D H
0 . 5 L S B
0 3 H
0 2 H
0 1 H
0
1
2
3
4 0 9 3 4 0 9 4 4 0 9 5 4 0 9 6
A n a l o g I n p u t V o l t a g e
Ideal A/D Transfer Function
; disable ADC interrupt
; select f
/8 as A/D clock
SYS
; Select VDD as ADC reference voltage and turn on ADONB bit
; setup ADPCR to configure pins AN0~AN7
; enable and connect AN0 channel to A/D converter
; high pulse on start bit to initiate conversion
; reset A/D
; start A/D
; poll the ADCR0 register EOCB bit to detect end of A/D conversion
; continue polling
; read low byte conversion result value
; save result to user defined register
; read high byte conversion result value
; save result to user defined register
87
1 . 5 L S B
V
o r V
D D
R E F
(
)
4 0 9 6
March 29, 2019
Need help?
Do you have a question about the HT45F23A and is the answer not in the manual?
Questions and answers