English
Language : 

BC66F840 Datasheet, PDF (145/242 Pages) Holtek Semiconductor Inc – 2.4GHz Flash RF TX/RX MCU
BC66F840/BC66F850/BC66F860
2.4GHz Flash RF TX/RX MCU
FFFH
FFEH
FFD H
A /D C o n v e r s io n
R e s u lt
03H
02H
01H
0
1 .5 L S B
0 .5 L S B
1
2
3
4093 4094 4095 4096
A n a lo g In p u t V o lta g e
Ideal A/D Transfer Function
(
V DD or V REF
4096
)
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 EOCB bit in the ADCR0 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 1: using an EOCB polling method to detect the end of conversion
clr ADE ; disable ADC interrupt
mov a,03H
mov ADCR1,a ; select fSYS/8 as A/D clock and switch off the internal Bandgap
; reference voltage
clr ADOFF
mov a,0Fh ; setup ACERL to configure pins AN0~AN3
mov ACERL,a
mov a,00h
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 EOCB
jmp polling_EOC
mov a,ADRL
mov ADRL_buffer,a
mov a,ADRH
mov ADRH_buffer,a
:
:
jmp start_conversion
; poll the ADCR0 register EOCB bit to detect end of A/D conversion
; continue polling
; read low byte conversion result value
; save result to user defined register
; read high byte conversion result value
; save result to user defined register
; start next a/d conversion
Rev. 1.40
145
May 24, 2017