A/D Programming Example - Holtek HT66F20 Manual

A/d flash mcu with eeprom
Table of Contents

Advertisement

HT66F20/HT66F30/HT66F40/HT66F50/HT66F60
HT66FU30/HT66FU40/HT66FU50/HT66FU60
A/D Flash MCU with EEPROM

A/D Programming Example

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: using an EOCB polling method to detect the end of conversion
clr ADE
mov a,03H
mov ADCR1,a
clr ADOFF
mov a,0Fh
mov ACERL,a
mov a,00h
mov ACERH,00h
mov a,00h
mov ADCR0,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 ; start next a/d conversion
Rev. 2.50
; disable ADC interrupt
; select f
/8 as A/D clock and switch off 1.25V
SYS
; setup ACERL and ACERH to configure pins AN0~AN3
; ACERH is only for HT66F60
; enable and connect AN0 channel to A/D converter
; high pulse on start bit to initiate conversion
; reset A/D
; start A/D
; 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
��9
��ne 22� 20��

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Table of Contents