
2–82
Motorola Sensor Device Data
For More Information On This Product,
  Go to: www.freescale.com
SOFTWARE SOURCE/ASSEMBLY PROGRAM CODE
******************************************************************************
*                                                                            *
*                 Pager Shock & Mute Detection Version 1.0                   *
*                                                                            *
*   The following code is written for MC68HC705B16 using MMDS05 software     *
*   Version 1.01                                                             *
*   CASM05 – Command line assembler Version 3.04                             *
*   P & E Microcomputer Systems, Inc.                                        *
*                                                                            *
*                         Written by : C.S. Chua                             *
*                             9th January 1997                               *
*                                                                            *
*                           Software Description                             *
*                                                                            *
*   J1 ON – Sound mode                                                       *
*   Buzzer will turn off if the accelerometer is tapped or switch S2 is      *
*   depressed.                                                               *
*                                                                            *
*   J1 OFF – Silence mode                                                    *
*   LED will turn off if and only if S2 is depressed                         *
*                                                                            *
******************************************************************************
******************************************
*                                        *
*            I/O Declaration             *
*                                        *
******************************************
PORTB        EQU     $01           ; Port B
PLMA         EQU     $0A           ; D/A to control buzzer
TCONTROL     EQU     $12           ; Timer control register
TSTATUS      EQU     $13           ; Timer Status Register
OCMPHI1      EQU     $16           ; Output Compare Register 1 High Byte
OCMPLO1      EQU     $17           ; Output Compare Register 1 Low Byte
TCNTHI       EQU     $18           ; Timer Count Register High Byte
TCNTLO       EQU     $19           ; Timer Count Register Low Byte
OCMPHI2      EQU     $1E           ; Output Compare Register 2 High Byte
OCMPLO2      EQU     $1F           ; Output Compare Register 2 Low Byte
******************************************
*                                        *
*        RAM Area ($0050 – $0100)        *
*                                        *
******************************************
             ORG     $50
STACK        RMB     4             ; Stack segment
TEMPTCNTLO   RMB     1             ; Temp. storage of timer result (LSB)
TEMPTCNTHI   RMB     1             ; Temp. storage of timer result (MSB)
******************************************
*                                        *
*        ROM Area ($0300 – $3DFD)        *
*                                        *
******************************************
             ORG     $300
******************************************
*                                        *
*   Program starts here upon hard reset  *
*                                        *
******************************************
RESET         CLR      PORTB             ; Initialise Ports
              LDA      #%01001000        ; Configure Port B
              STA      $05
              LDA      TSTATUS           ; Dummy read the timer status register so as to clear the OCF
              CLR      OCMPHI2
              CLR      OCMPHI1
              LDA      OCMPLO2
              JSR      COMPRGT
              LDA      #$40              ; Enable the output compare interrupt
              STA      TCONTROL
              LDA      #10               ; Idle for a while before ”beeping”
IDLE          JSR      DLY20
              DECA
              BNE      IDLE
              CLI                        ; Interrupt begins here
              BRSET    1,PORTB,SILENCE   ; Branch if J1 is off
              BSET     6,PORTB           ; Turn on accelerometer
              JSR      DLY20             ; Wait till the supply is stable
TEST          BRSET    5,PORTB,MUTE      ; Sample shock sensor for tapping
              BRCLR    7,PORTB,MUTE      ; Sample switch S2 for muting
              JMP      TEST
MUTE          BCLR     6,PORTB           ; Turn off accelerometer
              SEI
              CLR      PLMA              ; Turn off buzzer
F
Freescale Semiconductor, Inc.
n
.