E:\Robot\srf04b.lst - generated by MGTEK Assembler ASM11 V1.22 Build 137 for WIN32 (x86) - Fri Dec 09 12:31:10 2005

    1:          =00002000                      org $2000
    2:     2000 7E 2009                        jmp main
    3:                                 
    4:          =00001000              porta   equ $1000
    5:          =00001026              PACTL   equ $1026
    6:          =0000100E              tcnt    equ $100E
    7:          =00001023              tflg1   equ $1023
    8:          =00001022              tmsk1   equ $1022
    9:          =00001012              tic2    equ $1012
   10:          =00001021              tctl2   equ $1021
   11:          =0000FFC1              out2bsp equ $ffc1
   12:          =0000FFC4              outcrlf equ $ffc4
   13:                                 
   14:     2003 +0002                  Sonar_start     rmb 2
   15:     2005 +0002                  Sonar_end       rmb 2
   16:     2007 +0002                  Sonar_ans       rmb 2   
   17:     2009                        main:   
   18:                                 
   19:     2009                        Sonar:  
   20:                                 
   21:                                 ; add after testing (phase 1) is completed
   22:                                 ;
   23:                                 ;       psha
   24:                                 ;       pshb
   25:                                 ;       pshx
   26:                                 
   27:                                 
   28:     2009 CE 1026                        ldx #pactl      ; Set PA7 for OUTPUT
   29:     200C 1C 00 80                       bset 0,x #$80
   30:     200F CE 1000                        ldx #porta      ; Trigger on PA7 set high - Trigger pulse
   31:     2012 1C 00 80                       bset 0,x #$80
   32:     2015 FC 100E                        ldd tcnt        ; capture present time
   33:     2018 FD 2003                        std Sonar_start 
   34:     201B CE 1000                        ldx #porta      ; turn off trigger pulse
   35:     201E 1D 00 80                       bclr 0,x #$80
   36:                                 
   37:                                 
   38:     2021 CE 1021                        ldx #tctl2
   39:     2024 1C 00 08                       bset 0,x #$08
   40:     2027 1D 00 04                       bclr 0,x #$04   ;capture falling edge of PA1 (IC2)      
   41:                                 
   42:     202A 86 02                          ldaa #$02       ;clear flag for IC2
   43:     202C B7 1023                        staa tflg1
   44:                                         
   45:     202F                        sonar_l2:
   46:     202F B6 1023                        ldaa tflg1      ;wait for flag to go high
   47:     2032 84 02                          anda #$02
   48:     2034 27 F9                          beq sonar_l2
   49:                                 
   50:     2036 FC 1012                        ldd tic2        ;get time of falling edge and store
   51:     2039 FD 2005                        std Sonar_end
   52:                                 
   53:     203C FC 2005                        ldd Sonar_end           ;calculate time
   54:     203F B3 2003                        subd Sonar_start
   55:     2042 FD 2007                        std Sonar_ans
   56:                                 
   57:                                 ; remove after testing is complete
   58:     2045 CE 2007                        ldx #Sonar_ans  ;print time ticks in hex to screen
   59:     2048 BD FFC1                        jsr out2bsp
   60:     204B BD FFC4                        jsr outcrlf
   61:                                         
   62:     204E 7E 2009                        jmp Sonar
   63:                                 ;----------------------------------------------------------
   64:                                 
   65:                                         
   66:     2051 38                             pulx
   67:     2052 33                             pulb
   68:     2053 32                             pula
   69:                                 
   70:     2054 39                             rts

Symbols:
main                            *00002009
out2bsp                         *0000ffc1
outcrlf                         *0000ffc4
pactl                           *00001026
porta                           *00001000
sonar                           *00002009
sonar_ans                       *00002007
sonar_end                       *00002005
sonar_l2                        *0000202f
sonar_start                     *00002003
tcnt                            *0000100e
tctl2                           *00001021
tflg1                           *00001023
tic2                            *00001012

