English
Language : 

MC68HC812A4 Datasheet, PDF (303/342 Pages) Motorola, Inc – 16-bit device composed of standard on-chip peripheral modules connected by an intermodule bus. Modules include
Analog-to-Digital Converter (ATD)
Using the ATD to Measure a Potentiometer Signal
16.12 Using the ATD to Measure a Potentiometer Signal
This exercise allows the student to utilize the ATD on the HC12 to
measure a potentiometer signal output routed from the UDLP1 board to
the HC12 ATD pin PAD6. First the ATDCTL registers are initialized. A
delay loop of 100 µs is then executed. The resolution is set up followed
by a conversion set up on channel 6. After waiting for the status bit to
set, the result goes to the D accumulator. If the program is working
properly, a different value should be found in the D accumulator as the
left potentiometer is varied for each execution of the program.
16.12.1 Equipment
For this exercise, use the M68HC812A4EVB emulation board.
16.12.2 Code Listing
NOTE:
A comment line is deliminted by a semi-colon. If there is no code before
comment, an “;” must be placed in the first column to avoid assembly
errors.
; ----------------------------------------------------------------------
;
MAIN PROGRAM
; ----------------------------------------------------------------------
ORG
$7000
; 16K On-Board RAM, User code data area,
;
start main program at $7000
MAIN:
BSR
BSR
DONE: BRA
INIT
CONVERT
DONE
; Branch to INIT subroutine to Initialize ATD
; Branch to CONVERT Subroutine for conversion
; Branch to Self, Convenient place for breakpoint
; ----------------------------------------------
;
Subroutine INIT: Initialize ATD ;
; ----------------------------------------------
INIT:
LDAA
#$80
; Allow ATD to function normally,
STAA
ATDCTL2
; ATD Flags clear normally & disable interrupts
BSR
DELAY
; Delay (100 uS) for WAIT delay time.
LDAA
STAA
#$00
ATDCTL3
; Select continue conversion in BGND Mode
; Ignore FREEZE in ATDCTL3
LDAA
STAA
#$01
ATDCTL4
; Select Final Sample time = 2 A/D clocks
; Prescaler = Div by 4 (PRS4:0 = 1)
RTS
; Return from subroutine
Advance Information
MOTOROLA
Analog-to-Digital Converter (ATD)
MC68HC812A4 — Rev. 3.0
303