2–97
Motorola Sensor Device Data
For More Information On This Product,
Go to: www.freescale.com
APPENDIX — ASSEMBLY CODE LISTING FOR BASEBALL PITCH SPEEDOMETER
* Baseball Pitch Speedometer – Rev. 1.0
*
* Program waits for detection of impact via the input capture pin and then reads four A/D channels.
* The area under the Acceleration vs. Time curve is found by subtracting the steady state offsets
* from the digitized readings and summing the results. The sum is then divided by an empirically
* determined constant of proportionality, and the speed of the ball is displayed.
*
* Written by Carlos Miranda
* Systems and Applications
* Sensor Products Division
* Motorola Semiconductor Products Sector
* May 6, 1997
*
*
********************************************************************************************************
*
Although the information contained herein, as well as any information provided relative
*
thereto, has been carefully reviewed and is believed accurate, Motorola assumes no
*
liability arising out of its application or use, neither does it convey any license under
*
its patent rights nor the rights of others.
********************************************************************************************************
* These equates assign memory addresses to variables.
EEPROM
EQU
$B600
CODEBGN
EQU
$B60D
REGOFF
EQU
$1000
;Offset to access registers beyond direct addressing range.
PORTC
EQU
$03
PORTB
EQU
$04
DDRC
EQU
$07
TCTL2
EQU
$21
TFLG1
EQU
$23
ADCTL
EQU
$30
ADR1
EQU
$31
ADR2
EQU
$32
ADR3
EQU
$33
ADR4
EQU
$34
OPTION
EQU
$39
STACK
EQU
$01FF
;Starting address for the Stack Pointer.
RAM
EQU
$0000
* These equates assign specific masks to variables to facilitate bit setting, clearing, etc.
ADPU
EQU
$80
;Power up the analog to digital converter circuitry.
CSEL
EQU
$40
;Select the internal system clock.
CCF
EQU
$80
;Conversion complete flag.
IC1F
EQU
$04
;Input Capture 1 flag.
IC1FLE
EQU
$20
;Configure Input Capture 1 to detect falling edges only.
IC1FCLR
EQU
$FB
;Clear the Input Capture 1 flag.
CHNLS47
EQU
$14
;Select channels 4 through 7 with MULT option ON.
SAMPLES
EQU
$0200
;Number of A/D samples taken.
OC1F
EQU
$80
;Output Compare 1 flag.
OC1FCLR
EQU
$7F
;Clear the Output Compare flag.
CURDLY
EQU
$0098
;Timer cycles to create delay for displaying ”Your Speed.”
RAMBYTS
EQU
$19
;Number of RAM variables to clear during initialization.
ALLONES
EQU
$FF
YOURSPD
EQU
$01
PRPFCTR
EQU
$00AD
;This constant of proportionality was empirically determined.
* Variables used for computation.
ORG
RAM
OFFSET1
RMB
1
;One for each accelerometer.
OFFSET2
RMB
1
OFFSET3
RMB
1
OFFSET4
RMB
1
SUM1
RMB
2
;Area under the acceleration vs. time curve.
SUM2
RMB
2
SUM3
RMB
2
SUM4
RMB
2
GRNDSUM
RMB
2
COUNT
RMB
2
CURBIN
RMB
1
TEMPBIN
RMB
1
BCD
RMB
2
CURDSPL
RMB
2
MAXBIN
RMB
1
MAXDSPL
RMB
2
* LED seven segment display patterns table.
ORG
EEPROM
JMP
START
SEVSEG
FCB
%11111010
FCB
%01100000
FCB
%11011100
FCB
%11110100
FCB
%01100110
FCB
%10110110
FCB
%10111110
FCB
%11100000
FCB
%11111110
FCB
%11100110
*
*
*
*
F
Freescale Semiconductor, Inc.
n
.