HT66F20-1/HT66F30-1/HT68F20-1/HT68F30-1
Flash MCU with EEPROM
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 ADCR0 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 ADE
mov a,03H
mov ADCR1,a
clr ADOFF
mov a,0Fh
mov ACERL,a
mov a,00h
mov ADCR0,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
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
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 and switch off 1.25V
SYS
; setup ACERL to configure pins AN0~AN3
; 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
; start next a/d conversion
1�9
1 . 5 L S B
V
o r V
D D
(
4 0 9 6
4 0 9 3 4 0 9 4 4 0 9 5 4 0 9 6
�ove��e� ��� �01�
R E F
)
Need help?
Do you have a question about the HT66F20-1 and is the answer not in the manual?