Rev. 1.10
96
November 04, 2019
Rev. 1.10
97
November 04, 2019
HT45F5Q-3
Battery Charger Flash MCU
HT45F5Q-3
Battery Charger Flash MCU
Example: using the interrupt method to detect the end of conversion
clr ADE ; disable A/D converter interrupt
mov
a,03h ;
select
f
SYS
/8 as A/D clock and
mov SADC1,a ; select external channel input and external reference input
mov a,0Ah ; setup PBS0 to configure pin AN0 and pin VREF
mov PBS0,a
mov a,20h
mov SADC0,a ; enable A/D 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 A/D converter 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,SADOL ; read low byte conversion result value
mov SADOL_buffer,a ; save result to user defined register
mov a,SADOH ; 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