;FILENAME:   STLAB023.ASM
;DATE:       March 16, 1996
;TITLE:      DC motor starting and stopping control
;HARDWARE:   MLAB-121

; JAZZ-31 utilities subroutines

DM_SEC  EQU      003FH   ;Delay 1/1000 second

; Pin Interface

DCM_CTL EQU     P1.7    ;DC motor control
SENSOR  EQU     P3.2    ;sensor status

        $INCLUDE "J31H2.ASM"    ;Include file monitor program

INTFG   EQU     00H

        ORG     8100H

RES:    CLR     DCM_CTL         ;ON/OFF MOTOR
        MOV     R2,#0
RES1:   MOV     R3,#0
        DJNZ    R3,$
        DJNZ    R2,RES1
        SETB    DCM_CTL

MAIN:   JB      INTFG,DISP1
        JB      SENSOR,DISP1    ;CHECK SENSOR INPUT
        ADDC    A,#1
        DA      A
DISP1:  SETB    INTFG           ;INPUT SENSOR ACTIVE
DISP2:  MOV     HEXBUF+2,A
        PUSH    ACC
        LCALL   HTOS
        MOV     DISBUF,#39H     ;'C'
        MOV     DISBUF+1,#5CH   ;'o'
        MOV     DISBUF+2,#1CH   ;'u'
        MOV     DISBUF+3,#54H   ;'n'
        MOV     DISBUF+4,#78H   ;'t'
        MOV     DISBUF+5,#40H   ;'-'
        LCALL   SCANK
        CLR     DCM_CTL         ;ON/OFF MOTOR
        MOV     R2,#18H
DISP3:  MOV     R3,#40H
        DJNZ    R3,$
        DJNZ    R2,DISP3
        SETB    DCM_CTL
        POP     ACC

        JNB     SENSOR,MAIN
        CLR     INTFG
        SJMP    DISP2
        END


