
Rev. 1.21
112
�ove��e� ��� 2�1�
Rev. 1.21
113
�ove��e� ��� 2�1�
HT66F488/HT66F489
A/D Flash MCU with EEPROM
HT66F488/HT66F489
A/D Flash MCU with EEPROM
A/D Programming Examples
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 ; disable ADC interrupt
mov a,03H
mov ADCR1,a
; select f
SYS
/8 as A/D clock and switch off V
BG
clr ADOFF
mov a,0Fh
; setup ACER
L
to configure pins AN0~AN3
mov ACER
L,a
mov a,00h
mov ADCR0,a
; enable and connect AN0 channel to A/D converter
:
start_conversion:
clr START
; high pulse on start bit to initiate conversion
set START
; reset A/D
clr START
; start A/D
polling_EOC:
sz EOCB
; poll the ADCR0 register EOCB bit to detect end
of A/D conversion
jmp polling_EOC
; continue polling
mov a,ADRL
; read low byte conversion result value
mov ADRL_buffer,a ; save result to user defined register
mov a,ADRH
; read high byte conversion result value
mov ADRH_buffer,a ; save result to user defined register
:
:
jmp start_conversion ; start next a/d conversion