
432
CHAPTER 16 8/10-BIT A/D CONVERTER
r Coding example
BAPL
EQU 000100H
;Lower buffer address pointer
BAPM
EQU 000101H
;Middle buffer address pointer
BAPH
EQU 000102H
;Upper buffer address pointer
ISCS
EQU 000103H
;EI
OS status register
IOAL
EQU 000104H
;Lower I/O address register
IOAH
EQU 000105H
;Upper I/O address register
DCTL
EQU 000106H
;Lower data counter
DCTH
EQU 000107H
;Upper data counter
DDR5
EQU 000015H
;Port 5 direction register
ADER
EQU 000017H
;Analog input enable register
ICR00 EQU 0000B0H
;Interrupt control register for A/DC
ADCS0 EQU 000034H
;A/D control status register
ADCS1 EQU 000035H
;
ADCR0 EQU 000036H
;A/D data register
ADCR1 EQU 000037H
;
;-------Main program------------------------------------------------
CODECSEG
START:
;Assumes that the stack pointer (SP) has
already been initialized.
AND CCR,#0BFH
;Disables interrupts.
MOV ICR00,#00H
;Interrupt level:
0 (highest priority)
MOV BAPL,#00H
;Sets the address to which the conversion
data is transferred and stored.
MOV BAPM,#02H
;(Uses 200H to 205H.)
MOV BAPH,#00H
;
MOV ISCS,#18H
;Transfers word data, adds 1 to the
address, then transfers the data from
I/O to memory.
MOV IOAL,#36H
;Sets the address of the analog data
register as the
MOV IOAH,#00H
;transfer source address pointer.
MOV DCTL,#03H
;Sets the EI
OS transfer count to three,
which is the same value as the conversion
count.
MOV DDR5,#11110001B;Sets P51 to P53 as input.
MOV ADER,#00001110B;Sets P51/AN1 to P53/AN3 as analog inputs.
MOV DCTH,#00H
;
MOV ADCS0,#0BH
;Single activation.
Converts AN1 to AN3.
MOV ADCS1,#0A2H
;Software activation.
Begins A/D
conversion. Enables interrupts.
MOV ILM,#07H
;Sets ILM in PS to level 7.
OR
CCR,#40H
;Enables interrupts.
LOOP: MOV A,#00H
;Endless loop
MOV A,#01H
BRA LOOP
;-------Interrupt program-------------------------------------------
ED_INT1:
MOV I:ADCS1,#00H
;Stops A/D conversion.
Clears and disables
the interrupt flag.
RETI
;Returns from interrupt.
CODEENDS
;-------Vector setting----------------------------------------------
VECT CSEG ABS=0FFH
ORG
0FFD0H
;Sets vector for interrupt #11 (0BH)
DSL
ED_INT1