XC912BC32CFU8 Motorola Semiconductor Products, XC912BC32CFU8 Datasheet - Page 313

no-image

XC912BC32CFU8

Manufacturer Part Number
XC912BC32CFU8
Description
M68HC12B Family Data Sheet
Manufacturer
Motorola Semiconductor Products
Datasheet
17.5 Using the ATD to Measure a Potentiometer Signal
17.5.1 Equipment
17.5.2 Code Listing
; ----------------------------------------------------------------------
;
; ----------------------------------------------------------------------
;
MAIN:
DONE:
; ----------------------------------------------
;
; ----------------------------------------------
INIT:
M68HC12B Family — Rev. 8.0
MOTOROLA
ORG
BSR
BSR
BRA
LDAA
STAA
BSR
LDAA
STAA
LDAA
STAA
RTS
NOTE:
MAIN PROGRAM
Subroutine INIT: Initialize ATD
$7000
INIT
CONVERT
DONE
#$80
ATDCTL2
DELAY
#$00
ATDCTL3
#$01
ATDCTL4
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.
For this exercise, use the M68HC912B32EVB emulation board.
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.
Analog-to-Digital Converter (ATD)
; 16K On-Board RAM, User code data area,
; Branch to INIT subroutine to Initialize ATD
; Branch to CONVERT Subroutine for conversion
; Branch to Self, Convenient place for breakpoint
; Allow ATD to function normally,
; ATD Flags clear normally & disable interrupts
; Delay (100 uS) for WAIT delay time.
; Select continue conversion in BGND Mode
; Ignore FREEZE in ATDCTL3
; Select Final Sample time = 2 A/D clocks
; Prescaler = Div by 4 (PRS4:0 = 1)
; Return from subroutine
start main program at $7000
;
Using the ATD to Measure a Potentiometer Signal
Analog-to-Digital Converter (ATD)
Data Sheet
313

Related parts for XC912BC32CFU8