Program Example For A/D Converter; Program Example Of The A/D Conversion Functions - Fujitsu F2MC-8L F202RA Hardware Manual

F2mc-8l 8-bit microcontroller
Hide thumbs Also See for F2MC-8L F202RA:
Table of Contents

Advertisement

12.8

Program Example for A/D Converter

This section shows a program example of the 10-bit A/D converter.

Program Example of the A/D Conversion Functions

● Processing specifications
The analog voltage to be applied to the AN0 pin is converted to digital voltage through software activation.
In this example, completion of conversion is detected in a loop in the program without using interrupts.
● Coding example
PDR4
ADC1 EQU
ADC2 EQU
ADDH EQU
ADDL EQU
ADEN EQU
AN0
ADE0 EQU
ADI
ADMV EQU
AD
EXT
;------------------------Main program--------------------------------------------------------------------------------
AD_WAIT
AD_CONV
EQU
000FH
0030H
0031H
0032H
0033H
0034H
EQU
PDR4:0
ADEN:0
EQU
ADC1:3
ADC1:2
EQU
ADC1:0
EQU
ADC2:1
CSEG
:
SETB
AN0
CLRI
SETB
ADE0
CLRB
EXT
BBS
ADMV,AD_WAIT ; Loop for verifying that the A/D converter is stopped.
MOV
ADC1,#00000000B ; Selects analog input channel 0 (AN0), clears the
MOV
ADC2,#00000001B ; Disables the interrupt request output, selects A/D
SETI
:
SETB
AD
BBS
ADMV,AD_CONV ; Loop for waiting for completion of A/D conversion
CLRB
ADI
CHAPTER 12 A/D CONVERTER
; Address of port 4 data register 4
; Address of A/D control register 1
; Address of A/D control register 2
; Address of A/D data register H
; Address of A/D data register L
; Enables the A/D input pin.
; Defines the AN0 analog input.
; Enables the AN0 analog input.
; Defines the interrupt request flag bit.
; Defines the conversion in-progress flag bit.
; Defines the bit for activating A/D conversion (software
activation).
; Defines the bit for enabling continuous activation.
; [CODE SEGMENT]
; Sets the P40/AN0 pin to the analog input.
; Disables interrupts.
; Enables the AN0 pin.
; Disables continuous activation.
interrupt request flag, does not perform software
activation.
conversion functions, and selects software activation.
; Enables interrupts.
; Activates software.
(at about 12.2 µs/12.5 MHz)
; Clears the interrupt request flag.
277

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

F2mc-8l mb89202Mb89202/f202ra series

Table of Contents