Rev. 2.50 178 June 22, 2017 Rev. 2.50 179 June 22, 2017
HT66F20/HT66F30/HT66F40/HT66F50/HT66F60
HT66FU30/HT66FU40/HT66FU50/HT66FU60
A/D Flash MCU with EEPROM
HT66F20/HT66F30/HT66F40/HT66F50/HT66F60
HT66FU30/HT66FU40/HT66FU50/HT66FU60
A/D Flash MCU with EEPROM
A/D Programming Example
ThefollowingtwoprogrammingexamplesillustratehowtosetupandimplementanA/Dconversion.
Intherstexample,themethodofpollingtheEOCBbitintheADCR0registerisusedtodetect
whentheconversioncycleiscomplete,whereasinthesecondexample,theA/Dinterruptisusedto
determinewhentheconversioniscomplete.
Example: using an EOCB polling method to detect the end of conversion
clr ADE ; disable ADC interrupt
mov a,03H
movADCR1,a ;selectf
SYS
/8asA/Dclockandswitchoff1.25V
clrADOFF
mova,0Fh ;setupACERLandACERHtocongurepinsAN0~AN3
movACERL,a
mov a,00h
movACERH,00h ;ACERHisonlyforHT66F60
mov a,00h
movADCR0,a ;enableandconnectAN0channeltoA/Dconverter
:
start_conversion:
clrSTART ;highpulseonstartbittoinitiateconversion
setSTART ;resetA/D
clrSTART ;startA/D
polling_EOC:
szEOCB ;polltheADCR0registerEOCBbittodetectendofA/Dconversion
jmppolling_EOC ;continuepolling
mova,ADRL ;readlowbyteconversionresultvalue
movADRL_buffer,a ;saveresulttouserdenedregister
mova,ADRH ;readhighbyteconversionresultvalue
movADRH_buffer,a ;saveresulttouserdenedregister
:
:
jmpstart_conversion ;startnexta/dconversion