English
Language : 

HT46R068B_15 Datasheet, PDF (76/135 Pages) Holtek Semiconductor Inc – Enhanced A/D 8-Bit OTP MCU
HT46R068B/HT46R069B
Enhanced A/D 8-Bit OTP MCU
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 ; disable ADC interrupt
mov a,00000001B
mov ACSR,a ; select fSYS/8 as A/D clock and ADONB=0
mov a,0Fh ; setup ANCSR0 and ANCSR1 to configure pins AN0~AN3
mov ANCSR0,a
mov a, 00h
mov ANCSR1,a ;
mov a,00000000B ;
mov ADCR,a ; select AN0 to be connected to the A/D converter
:
Start_conversion:
clr START
set START ; reset A/D
clr START ; start A/D
Polling_EOC:
sz EOCB ; poll the ADCR 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
Note: To power off ADC module, it is necessary to set ADONB as "1".
Rev. 1.50
76
February 05, 2015