English
Language : 

HT45F5Q Datasheet, PDF (80/114 Pages) Holtek Semiconductor Inc – Charger Flash MCU
HT45F5Q
Charger Flash MCU
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 ADBZ bit in the SADC0 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 ADBZ polling method to detect the end of conversion
clr ADE
; disable ADC interrupt
mov a,03H
mov SADC1,a ; select fSYS/8 as A/D clock and switch off the bandgap reference
; voltage
mov a,01h ; setup PASR to configure pin AN0
mov PASR,a
mov a,00h
mov SADC0,a ; enable and connect AN0 channel to A/D converter
set ENADC
:
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 ADBZ ; poll the SADC0 register ADBZ bit to detect end of A/D conversion
jmp polling_EOC ; continue polling
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
:
:
jmp start_conversion ; start next A/D conversion
Rev. 1.10
80
December 13, 2016