
12-22 Chapter 12 A/D Converter
MB89190/190A series
T Example program for sense function
Processing specifications
– An interrupt occurs when the analog voltage input to the AN0 pin is lower than 3.0 V.
– The sense function is started continuously using the output (original oscillation divided by 2
8) of the
time-base timer.
– When the analog power supply voltage (Vcc) = reference voltage (AVR) = 5.0 V, the value of the
ADCD register corresponding to a compare voltage of 3.0 V is 0A9H.
Also, when the original oscillation is 4.2 MHz, the continuous starting cycle is about 61.0 s (2
8/4.2
MHz).
Coding example
PDR4
EQU
000EH
; Address of port data register
ADC1
EQU
0020H
; Address of A/D control register 1
ADC2
EQU
0021H
; Address of A/D control register 2
ADCD
EQU
0022H
; Address of A/D data register
ADI
EQU
ADC1:3
; Definition of interrupt request flag bit
ADMV
EQU
ADC1:2
; Definition of conversion-on flag bit
AD
EQU
ADC1:0
; Definition of A/D conversion start bit (start by software)
EXT
EQU
ADC2:1
; Definition of continuous start enable bit
ILR2
EQU
007DH
; Interrupt level setting register set
INT_V
DSEG
ABS
;[DATA SEGMENT]
ORG
FFEEH
IRQ6
DW
WARI
INT_V
ENDS
;---------- Main program ---------------------------------------------------------------------
CSEG
;[CODE SEGMENT]
; Stack pointer (SP), etc., assumed initialized
:
MOV
DDR0, #00000000B
; #XXXXXXX0B allowed
P00/AN0 pin set to analog input pin
CLRI
; Interrupt disabled
MOV
ILR3, #11011111B
; Interrupt level (level 1) set
CLRB
EXT
; Continuous start disabled
AD_WAIT
BBS
ADMV,AD_WAIT
; A/D converter stop check loop
MOV
ADCD, #9AH
; Compare voltage data (3.0 V) set
MOV
ADC1,#00000000B
; Analog input channel 0 selected (AN0). The interrupt
request flag is cleared, the comparison condition is set
(an interrupt occurs when the input voltage is lower than
the compare voltage), and software is not started.
MOV
ADC2,#00011111B
; Output of time-base timer enabled, output of interrupt
request enabled, sense function selected, and continuous
starting enabled
SETI
; Interrupt enabled
:
;---------- Interrupt-processing routine -----------------------------------------------------
WARI
CLRB
ADI
; Interrupt request flag cleared
PUSHW
A
XCHW
A, T
PUSHW
A
:
Processing by user
:
POPW
A
XCHW
A, T
POPW
A
RETI
ENDS
;---------------------------------------------------------------------------------------------
END