Program Example For A/D Converter - Fujitsu F2MC-8L MB89620 Series Hardware Manual

8-bit microcontroller
Table of Contents

Advertisement

7
13.

Program Example for A/D Converter

This section gives program examples for the A/D conversion and sense functions of
the 8-bit A/D converter.
n Program Example for A/D Conversion Function
l
Processing description
Performs software-activated A/D conversion of the analog voltage input to the AN0 pin. The
example does not use interrupts and detects conversion completion within the program loop.
l
Coding example
PDR5
ADC1
ADC2
ADCD
AN0
ADI
ADMV
AD
EXT
;-----Main program----------------------------------------------------------------------------------------------------------------------------------------
AD_WAIT
AD_CONV
;---------------------------------------------------------------------------------------------------------------------------------------------------------------
260
CHAPTER 13 A/D CONVERTER
EQU
0010H
EQU
0020H
EQU
0021H
EQU
0022H
EQU
PDR5:0
EQU
ADC1:3
EQU
ADC1:2
EQU
ADC1:0
EQU
ADC2:1
CSEG
:
SETB
AN0
CLRI
CLRB
EXT
BBS
ADMV,AD_WAIT
MOV
ADC1,#00000000B
MOV
ADC2,#00000001B
SETI
:
SETB
AD
BBS
ADMV,AD_CONV
CLRB
ADI
MOV
A,ADCD
:
:
ENDS
END
; Port 5 data register
; A/D control register 1
; A/D control register 2
; A/D data register
; Define the AN0 analog input pin.
; Define the interrupt request flag bit.
; Define the conversion-in-progress flag bit.
; A/D converter activation bit (software activation)
; Define the continuous activation enable bit.
; [CODE SEGMENT]
; Set P50/AN0 pin as an analog input pin (AN0).
; Disable interrupts.
; Disable continuous activation.
; Loop to check that the A/D converter is stopped.
; Select analog input channel 0 (AN0),
clear interrupt request flag, and do not activate by software.
; Disable interrupt request output, select the A/D conversion
function, and select software activation by the AD bit.
; Enable interrupts.
; Activate by software
; Loop to delay until A/D conversion completes (approx. 17.6 µs
/10 MHz).
; Clear interrupt request flag.
; Read A/D conversion data.
MB89620 series

Advertisement

Table of Contents
loading

Table of Contents