mov a,ADRH ; read conversion result from the high byte
; ADRH register
mov adrh_buffer,a ; save result to user defined register
mov a,ADRL ; read conversion result from the low byte ADRL
; register
mov adrl_buffer,a ; save result to user defined register
:
:
jmp start_conversion ; start next A/D conversion
Example: using Interrupt method to detect end of conversion
set INTC0.0 ; interrupt global enable
set INTC0.3 ; enable A/D interrupt in interrupt control
; register
mov a,00100000B
mov ADCR,a ; setup ADCR register to configure Port PB0~PB3
; as A/D inputs and select AN0 to be connected
; to the A/D converter
mov a,00000001B
mov ACSR,a ; setup the ACSR register to select f
SYS
/8 as
; the A/D clock
start_conversion:
clr ADCR.7
set ADCR.7 ; reset A/D
clr ADCR.7 ; start A/D
:
:
; interrupt service routine
EOC_service routine:
mov a_buffer,a ; save ACC to user defined register
mov a,ADRH ; read conversion result from the high byte
; ADRH register
mov adrh_buffer,a ; save result to user defined register
mov a,ADRL ; read conversion result from the low byte ADRL
; register
mov adrl_buffer,a ; save result to user defined register
clr ADCR.7
set ADCR.7 ; reset A/D
clr ADCR.7 ; start A/D
mov a,a_buffer ; restore ACC from temporary storage
reti
A/D Transfer Function
As the HT46R47/HT46C47 and HT46R22/HT46C22 devices each contain a 9-bit A/D converter,
their full-scale converted digitized value is equal to 1FFH. Since the full-scale analog input value is
equal to the VDD voltage, this gives a single bit analog input value of V
DD
/512. In the case of the
HT46R23/HT46C23 and HT46R24/HT46C24 devices, which each contain a 10-bit A/D converter,
their full-scale converted digitized value is equal to 3FFH, giving a single bit analog input value of
V
DD
/1024. The following graphs show the ideal transfer function between the analog input value
and the digitized output value for both the 9-bit and 10-bit A/D converters.
52
A/D Type MCU