Rev. 1.50 128 August 28, 2017 Rev. 1.50 129 August 28, 2017
HT66F0175/HT66F0185
A/D Flash MCU with EEPROM
HT66F0175/HT66F0185
A/D Flash MCU with EEPROM
A/D Programming Examples
ThefollowingtwoprogrammingexamplesillustratehowtosetupandimplementanA/Dconversion.
Intherstexample,themethodofpollingtheADBZbitintheSADC0registerisusedtodetect
whentheconversioncycleiscomplete,whereasinthesecondexample,theA/Dinterruptisusedto
determinewhentheconversioniscomplete.
Example: using an ADBZ polling method to detect the end of conversion
clr ADE ; disable ADC interrupt
mov a,03H
mov SADC1,a ; select f
SYS
/8 as A/D clock and switch off V
BG
voltage
set ADCEN
mov a,03H ; setup ACERL to congure pin AN0
mov ACERL,a
mov a,00H
mov SADC0,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
:
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 dened register
mov a,SADOH ; read high byte conversion result value
mov SADOH_buffer,a ; save result to user dened register
:
jmp start_conversion ; start next A/D conversion