Rev. 1.71
106
April 11, 2017
Rev. 1.71
107
April 11, 2017
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
HT66F002/HT66F0025/HT66F003/HT66F004
Cost-Effective A/D Flash MCU with EEPROM
Example: using the interrupt method to detect the end of conversion
clr ADE ; disable ADC interrupt
mov a,0BH
mov
S
ADC1,a ; select f
SYS
/8 as A/D clock and switch off the bandgap reference voltage
set
ENADC
mov a,03h
; setup
PASR to configure pin AN0
mov
PASR
,a
mov a,20h
mov
S
ADC0,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
clr ADF
; clear ADC interrupt request flag
set ADE ; enable ADC interrupt
set EMI
; enable global interrupt
:
:
; ADC interrupt service routine
ADC_ISR:
mov acc_stack,a
; save ACC to user defined memory
mov a,STATUS
mov status_stack,a
; save STATUS to user defined memory
:
:
mov a,
SADO
L ; read low byte conversion result value
mov
SADOL_buffer,a ; save result to user defined register
mov a,
SADO
H ; read high byte conversion result value
mov
SADOH_buffer,a ; save result to user defined register
:
:
EXIT_INT_ISR:
mov a,status_stack
mov STATUS,a
; restore STATUS from user defined memory
mov a,acc_stack
; restore ACC from user defined memory
reti