EasyManua.ls Logo

Holtek BS66F340 - A;D Programming Examples

Default Icon
242 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Rev. 1.60 154 August 20, 2019 Rev. 1.60 155 August 20, 2019
BS66F340/BS66F350/BS66F360/BS66F370
Touch A/D Flash MCU with LED Driver
BS66F340/BS66F350/BS66F360/BS66F370
Touch A/D Flash MCU with LED Driver
The A/D Converter input voltage value can be calculated using the following equation:
A/D input voltage = A/D output digital value × V
REF
÷ 4096
The diagram shows the ideal transfer function between the analog input value and the digitised
output value for the A/D converter. Except for the digitised zero value, the subsequent digitised
values will change at a point 0.5 LSB below where they would change without the offset, and the
last full scale digitised value will change at a point 1.5 LSB below the V
REF
level.













   



Ideal A/D Transfer Function
A/D Programming Examples
The following two programming examples illustrate how to setup and implement an A/D
conversion. In the rst 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 f
SYS
/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 congure 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 dened register
mov a,ADRH ; read high byte conversion result value
mov ADRH_buffer,a ; save result to user dened register
:
jmp start_conversion ; start next A/D conversion

Table of Contents

Related product manuals