;******************************************************************* ; ICEBREAKER FIRING PROGRAM ; Designed for 16F628A prototype board - change I/O for production circuit ; Includes the NEW 4-MHz clock routine. ; Includes timed mode and manual mode, ; Includes manual mode time limit. ;******************************************************************* ; DISABLE MASTERCLEAR AND WDT WHEN PROGRAMMING. ;******************************************************************* ; ;==========COMPILER DIRECTIVES SECTION=============================== LIST p=16F628A ;Use 16F628A include "P16F628A.INC" cblock 0x20 ;Edit general purpose registers... count1 counta countb countv endc ;==========CPU EQUATES SECTION======================================= SOL Equ 0 ;Set pin outputs SOLLED Equ 1 LEDMAN Equ 3 LEDTIMED Equ 5 POWERLED Equ 7 TRIG Equ 0 ;Set pin inputs MODESW Equ 1 INPORT Equ PORTA ;Call PortA "INPORT" OUTPORT Equ PORTB ;Call PortB "OUTPORT" ;===========DATA DEFINITIONS SETUP=================================== org 0x0000 ;Start program movlw 0x07 movwf CMCON ;Disable comparators - allows for general I/O. bsf STATUS, RP0 ;Select bank 1 movlw b'00011111' movwf TRISA ;PortA all inputs movlw b'00000000' movwf TRISB ;PortB all outputs bcf STATUS, RP0 ;Select bank 0. ;===========MAIN PROGRAM======================================= clrf PORTB ;Disable all outputs bsf PORTB, POWERLED ;Indicator LED Loop nop nop bcf PORTB, SOL ;Disable solenoid/LED bcf PORTB, SOLLED btfss PORTA, MODESW ;Bit check mode switch goto Manmode goto Timedmode ; ;===========ACTION SUBROUTINES=================================== Manmode bsf PORTB, LEDMAN ;LED indicator bcf PORTB, LEDTIMED btfsc PORTA, TRIG ;Bit check trigger goto Loop movlw d'20' ;Debounce time Call Delay ;Call subroutine btfsc PORTA, TRIG ;Bit check trigger goto Loop ;Disregard bsf PORTB, SOL ;Enable firing bsf PORTB, SOLLED clrf countv ;Valve open counter movlw d'25' ;Loop this number of times movwf countv Manfire ;Keep firing loop movlw d'20' ;Loop time Call Delay btfsc PORTA, TRIG ;Bit check trigger goto Firedis ;Disable Decfsz countv, f ;Decrement count goto Manfire ;Keep firing goto Firedis ;Disable firing ; Timedmode bcf PORTB, LEDMAN ;LED indicator bsf PORTB, LEDTIMED btfsc PORTA, TRIG ;Bit check trigger goto Loop movlw d'20' ;Debounce time Call Delay ;Call sub btfsc PORTA, TRIG ;Bit check trigger goto Loop ;Disregard bsf PORTB, SOL ;Enable firing bsf PORTB, SOLLED movlw d'100' ;Solenoid dwell time Call Delay nop ;Firing complete Firedis ;Stop firing routine bcf PORTB, SOL ;Deactivate solenoid bcf PORTB, SOLLED btfss PORTA, TRIG ;Bit check trigger goto Firedis goto Loop ;Start over ;===========GLOBAL SUBROUTINES================================= Delay ;4-MHz delay subroutine movwf count1 d1 movlw 0xC7 movwf counta movlw 0x01 movwf countb Delay_0 decfsz counta, f goto $+2 decfsz countb, f goto Delay_0 decfsz count1, f goto d1 retlw 0x00 end ;END OF PROGRAM