English
Language : 

BS67F340 Datasheet, PDF (177/281 Pages) Holtek Semiconductor Inc – Enhanced Touch A/D Flash MCU with LCD Driver
BS67F340/BS67F350/BS67F360/BS67F370
Enhanced Touch A/D Flash MCU with LCD Driver
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 ADCR 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
set VREFP_EXT ; deselect the temperature sensor reference voltage
mov a,03H ; select fSYS/8 as A/D clock and A/D internal power supply
mov ADCR1,a ; as reference voltage
set ADCEN
mov a,03H ; setup PBS0 to configure pin AN0
mov PBS0,a
mov a,20H
mov ADCR0,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 ADCR0 register ADBZ bit to detect end of A/D conversion
jmp polling_EOC ; continue polling
:
mov a,ADRL ; read low byte conversion result value
mov ADRL_buffer,a ; save result to user defined register
mov a,ADRH ; read high byte conversion result value
mov ADRH_buffer,a ; save result to user defined register
:
jmp start_conversion ; start next A/D conversion
Rev. 1.40
177
December 15, 2016