
438
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
;EI2OS status registerr
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
;
TMCSR1:L EQU
000086H
;Control status register 1
TMCSR1:H EQU
000087H
;
TMRLR1
EQU
000088H
;16-bit reload register
TMRHR1
EQU
000089H
;
;-------Main program------------------------------------------------
CODE
CSEG
START:
;Assumes that the stack pointer (SP)
has already been initialized.
AND
CCR,#0BFH
;Disables interrupts.
MOV
ICR00,#08H
;Interrupt level:
0 (highest
priority).
MOV
BAPL,#00H
;Sets the address to which conversion
data is stored.
MOV
BAPM,#06H
;(Uses 600H to 617H.)
MOV
BAPH,#00H
;
MOV
ISCS,#19H
;Transfers word data, adds 1 to
the address,
;transfers from I/O to memory, then
;ends by aresource request.
MOV
IOAL,#36H
;Sets the address of the analog
data register as the
MOV
IOAH,#00H
;transfer source address pointer.
MOV
DCTL,#0CH
;Transfers only channel 3 twelve
times by
EI2OS
MOV
DDR5,#00000000B;Sets P50 to P57 as input.
MOV
ADER,#00001000B;Sets P53/AN3 as analog input.
MOV
ADCS0,#0DBH
;Stop conversion mode.
Converts
AN3 CH.
MOV
ADCS1,#0A8H
;Activates the 16-bit timer, starts A/D
conversion, and enables interrupts.
MOVW TMRLR1,#0320H
;Sets the timer value to 800 (320H),
100 s.
MOV
TMCRH1,#00H
;Sets the clock source to 125 ns and
disables external trigger.
MOV
TMCRL1,#12H
;Disables timer output, disables
interrupts, and enables reload.
MOV
TMCRL1,#13H
;Activates the 16-bit timer.
MOV
ILM,#07H
;Sets ILM in PS to level 7.
OR
CCR,#40H
;Enables interrupts.
LOOP:
MOV
A,#00H
;Endless loop