A/D Programming Example - Holtek HT46R003B Manual

Cost-effective a/d 8-bit otp mcu
Table of Contents

Advertisement

HT46R003B
Cost-Effective A/D 8-bit OTP MCU
Note that to reduce the quantisation error, a 0.5 LSB offset is added to the A/D Converter input.
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 digitized value will change
at a point 1.5 LSB below the V
A / D C o n v e r s i o n
R e s u l t

A/D Programming Example

The following two programming examples illustrate how to set and implement an A/D conversion.
In the first example, the method of polling the EOCB 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 EOCB polling method to detect the end of conversion
clr ADE
mov a,00000001B
mov ACSR,a
mov a,00011111B
mov ADPCR,a
mov a,00000000B
mov ADCR,a
:
Start_conversion:
clr START
set START
clr START
Polling_EOC:
sz EOCB
jmp polling_EOC
mov a,ADRL
mov adrl_buffer,a
mov a,ADRH
mov adrh_buffer,a
:
jmp start_conversion
Rev. 1.00
level.
DD
F F F H
F F E H
F F D H
0 . 5 L S B
0 3 H
0 2 H
0 1 H
1
2
0
Ideal A/D Transfer Function
; disable A/D Converter interrupt
; select f
/8 as A/D clock and ADONB=0
SYS
; setup ADCR register to configure I/O Port as A/D inputs
; select AN0 to be connected to the A/D converter:
; reset A/D
; start A/D
; poll the ADCR 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
51
1 . 5 L S B
3
4 0 9 3 4 0 9 4 4 0 9 5 4 0 9 6
A n a l o g I n p u t V o l t a g e
V
D D
(
)
4 0 9 6
��ne 1�� �01�

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the HT46R003B and is the answer not in the manual?

Table of Contents