Fujitsu F2MC-8L MB89620 Series Hardware Manual page 282

8-bit microcontroller
Table of Contents

Advertisement

n Program Example for Sense Function
l
Processing description
Generates an interrupt if the analog voltage input to the AN0 pin is less than 3.0 V.
Perform continuous activation of the sense function synchronized with pulses input to the
ADST pin.
For analog power supply voltage (AV
register value of 0A9H gives a compare voltage of 3.0 V.
l
Coding example
DDR3
PDR5
ADC1
ADC2
ADCD
AN0
ADI
ADMV
AD
EXT
ILR3
INT_V
IRQ9
INT_V
;-----Main program----------------------------------------------------------------------------------------------------------------------------------------
AD_WAIT
;-----Interrupt processing routine----------------------------------------------------------------------------------------------------------------------
WARI
;---------------------------------------------------------------------------------------------------------------------------------------------------------------
MB89620 series
EQU
000DH
EQU
0010H
EQU
0020H
EQU
0021H
EQU
0022H
EQU
PDR5:0
EQU
ADC1:3
EQU
ADC1:2
EQU
ADC1:0
EQU
ADC2:1
EQU
007EH
DSEG
ABS
ORG
0FFE8H
DW
WARI
ENDS
CSEG
:
SETB
AN0
MOV
DDR3,#00000000B
CLRI
MOV
ILR3,#11110111B
CLRB
EXT
BBS
ADMV,AD_WAIT
MOV
ADCD,#9AH
MOV
ADC1,#00000000B
MOV
ADC2,#00011111B
SETI
:
CLRB
ADI
PUSHW
A
XCHW
A,T
PUSHW
A
:
User processing
:
POPW
A
XCHW
A,T
POPW
A
RETI
ENDS
END
) = reference voltage (AVR) = 5.0 V, an ADCD
CC
; Port 3 data direction register
; 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.
; Set interrupt level setting register 3.
; [DATA SEGMENT]
; [CODE SEGMENT]
; Stack pointer (SP) etc. are already initialized.
; Set P50/AN0 pin as an analog input pin.
; Set P30/ADST pin as an input.
; Disable interrupts.
; Set interrupt level (level 1).
; Disable continuous activation.
; Loop to check that the A/D converter is halted.
; Set compare voltage data (3.0 V).
; Select analog input channel 0 (AN0), clear interrupt request flag,
set compare condition (interrupt if the input voltage
is lower), and do not activate by software.
; Select external clock, enable interrupt request output, select the
sense function, and enable continuous activation.
; Enable interrupts.
; Clear interrupt request flag.
CHAPTER 13 A/D CONVERTER
13
261

Advertisement

Table of Contents
loading

Table of Contents