;************************************************************** ; ; -=[ Lock-Flash ]=- V1.20 23.04.2004 ; ; (C) by CoolChip ; ;************************************************************** ; ; Taktfrequenz: Interne 4 MHz ; ; Pinbelegung ; ---------------------------------- ; GPIO: 0 OUT Blinker Links ; 1 OUT Blinker Rechts ; 2 IN Schloss Auf ; 3 IN Schloss Zu ; 4 IN Jumper B ; 5 IN Jumper A ; ;************************************************************** ; Befehle für COMPILER oder BURNER ; processor 12f629 #include ERRORLEVEL -302 ;SUPPRESS BANK SELECTION MESSAGES ; ; Boden off, Code Protection off, Data Protectioon off, Power-on-Timer off, ; Watchdog off, Master Cear off, Interner-Oscillator ; __CONFIG _BODEN_OFF & _CP_OFF & _PWRTE_OFF & _WDT_OFF & _MCLRE_OFF & _INTRC_OSC_NOCLKOUT ; ;************************************************************** ; Variablen festlegen 20h ... 5Fh ; xflags equ 0x20 ; Platz für zusätzliche Flags W_save equ 0x21 ; Backup für Akku Status_save equ 0x22 ; Backup für Status-Bits loops equ 0x25 ; Zähler für Warteschleife loops2 equ 0x26 ; Zähler für untere Warteschleife ; Flag bits (FLAGS) ; #define close_akt xflags, 0 ; Öffen-Aktion #define open_akt xflags, 1 ; Schließ-Aktion #define links GPIO, 0 #define rechts GPIO, 1 #define open GPIO, 2 #define close GPIO, 3 #define jmpB GPIO, 4 #define jmpA GPIO, 5 ; ;*********************************************************************** ; Sprung zum Programmanfang org 0x0000 goto init ; ;*********************************************************************** ; Interruptroutine org 0x0004 movwf W_save ; erstmal Backup machen swapf STATUS, W bcf STATUS, RP0 ; Bank0 movwf Status_save bcf INTCON, GIE ; Interupt generell verbieten bcf links bcf rechts call pause50 ; Pause wegen Prellen btfsc open ; aufschließen? goto react ; Jo btfss close ; zuschließen? goto intFail ; Nö react btfsc open bsf open_akt btfsc open bcf close_akt btfsc close bsf close_akt btfsc close bcf open_akt waitforend btfsc open ; aufschließen? goto waitforend ; Jo btfsc close ; zuschließen? goto waitforend ; Jo intEnde swapf Status_save, w movwf STATUS swapf W_save,f swapf W_save,w bcf INTCON, GPIF ; GPIO-Interrupt löschen bsf INTCON, GIE ; Interupt generell erlauben goto main intFail swapf Status_save, w movwf STATUS swapf W_save,f swapf W_save,w bcf INTCON, GPIF ; GPIO-Interrupt löschen bsf INTCON, GIE ; Interupt generell erlauben retfie ; ;************************************************************** ; Initialisierung ; init ; interner Taktgenerator bsf STATUS, RP0 ; Bank 1 call 0x3FF movwf OSCCAL ; 4-MHz-Kalibrierung bcf STATUS, RP0 ; Bank 0 ; 12F629 alle Comparatoreingänge auf Digital umschalten ; alles in der Bank 0 bsf CMCON, CM0 bsf CMCON, CM1 bsf CMCON, CM2 ; ** Ports vorbereiten ** bsf STATUS, RP0 ; Bank 1 movlw b'111100' ; 0 = Output - 1 = Input movwf TRISIO bcf STATUS, RP0 ; Bank0 ; GPIO-Interrupt einstellen bsf INTCON, GPIE ; GPIO-Interupt erlauben bsf STATUS, RP0 ; Bank 1 movlw b'001100' ; 0 = NoInt - 1 = Interupt erlauben movwf IOC bcf STATUS, RP0 ; Bank 0 bcf INTCON, GPIF ; GPIO-Interrupt löschen bsf INTCON, GIE ; Interupt generell erlauben ; ** Register/Flags löschen ** ; clrf xflags ; 'xflags' löschen clrf GPIO ; ** ENDE der Initalisierung ** ; Signal bsf links bsf rechts call pause100 bcf links bcf rechts call pause250 bsf links bsf rechts call pause100 bcf links bcf rechts call pause250 ; ;********************************************************** ; Hauptprogrammschleife ; main btfsc open_akt ; aufschließen? goto blink_auf ; Jo btfsc close_akt ; zuschließen? goto blink_zu ; Jo goto main ; ;********************************************************** ; Blink-Programm beim Öffnen ; ; Signal gedreht über Jumper A? blink_auf btfsc jmpA goto blink_zu_go ; BigFlash oder Normal? (Jumper B) blink_auf_go btfss jmpB goto bigflash_open ; Normales Standart-Blinken normal_open bsf links bsf rechts call pause150 bcf links bcf rechts call pause250 bsf links bsf rechts call pause150 bcf links bcf rechts call pause250 clrf xflags ; 'xflags' löschen goto main ; BigFlash bigflash_open bsf links call pause50 bcf links call pause10 bsf rechts call pause50 bcf rechts call pause10 bsf links call pause50 bcf links call pause10 bsf rechts call pause50 bcf rechts call pause10 bsf links call pause50 bcf links call pause25 bsf rechts call pause50 bcf rechts call pause25 bsf links call pause50 bcf links call pause25 bsf rechts call pause50 bcf rechts call pause25 bsf links call pause50 bcf links call pause50 bsf rechts call pause50 bcf rechts call pause50 bsf links call pause50 bcf links call pause50 bsf rechts call pause50 bcf rechts call pause50 bsf links call pause50 bcf links call pause75 bsf rechts call pause50 bcf rechts call pause75 bsf links call pause50 bcf links call pause75 bsf rechts call pause50 bcf rechts call pause75 bsf links call pause50 bcf links call pause100 bsf rechts call pause50 bcf rechts call pause100 bsf links call pause50 bcf links call pause125 bsf rechts call pause50 bcf rechts call pause125 bsf links call pause50 bcf links call pause150 bsf rechts call pause50 bcf rechts call pause150 bsf links call pause50 bcf links call pause175 bsf rechts call pause50 bcf rechts call pause175 bsf links call pause50 bcf links call pause200 bsf rechts call pause50 bcf rechts call pause200 ; ----------- call pause250 call pause250 bsf links bsf rechts call pause150 bcf links bcf rechts call pause250 bsf links bsf rechts call pause250 call pause250 bcf links bcf rechts clrf xflags ; 'xflags' löschen goto main ; ;********************************************************** ; Blink-Programm beim Schließen ; ; Signal gedreht über Jumper A? blink_zu btfsc jmpA goto blink_auf_go ; BigFlash oder Normal? (Jumper B) blink_zu_go btfss jmpB goto bigflash_close ; Normales Standart-Blinken normal_close bsf links bsf rechts call pause150 bcf links bcf rechts call pause250 clrf xflags ; 'xflags' löschen goto main ; BigFlash bigflash_close bsf links call pause50 bcf links call pause200 bsf rechts call pause50 bcf rechts call pause200 bsf links call pause50 bcf links call pause175 bsf rechts call pause50 bcf rechts call pause175 bsf links call pause50 bcf links call pause150 bsf rechts call pause50 bcf rechts call pause150 bsf links call pause50 bcf links call pause125 bsf rechts call pause50 bcf rechts call pause125 bsf links call pause50 bcf links call pause100 bsf rechts call pause50 bcf rechts call pause100 bsf links call pause50 bcf links call pause75 bsf rechts call pause50 bcf rechts call pause75 bsf links call pause50 bcf links call pause75 bsf rechts call pause50 bcf rechts call pause75 bsf links call pause50 bcf links call pause50 bsf rechts call pause50 bcf rechts call pause50 bsf links call pause50 bcf links call pause50 bsf rechts call pause50 bcf rechts call pause50 bsf links call pause50 bcf links call pause25 bsf rechts call pause50 bcf rechts call pause25 bsf links call pause50 bcf links call pause25 bsf rechts call pause50 bcf rechts call pause25 bsf links call pause50 bcf links call pause10 bsf rechts call pause50 bcf rechts call pause10 bsf links call pause50 bcf links call pause10 bsf rechts call pause50 bcf rechts call pause10 ; ----------- call pause250 call pause250 bsf links bsf rechts call pause150 bcf links bcf rechts clrf xflags ; 'xflags' löschen goto main ; ;************************************************************** ; Pause-Routine ; pause1s call pause250 call pause250 call pause250 call pause250 return pause250 movlw D'250' ; 250 ms Pause movwf loops call wai return pause200 movlw D'200' ; 200 ms Pause movwf loops call wai return pause175 movlw D'175' movwf loops call wai return pause150 movlw D'150' movwf loops call wai return pause125 movlw D'125' movwf loops call wai return pause100 movlw D'100' movwf loops call wai return pause75 movlw D'75' movwf loops call wai return pause50 movlw D'50' movwf loops call wai return pause25 movlw D'25' ; 25 ms Pause movwf loops call wai return pause10 movlw D'10' ; 10 ms Pause movwf loops call wai return pause1 movlw D'1' ; 1 ms Pause movwf loops call wai return ; Warteschleife für 1 ms wai movlw D'110' ; Zeitkonstante für 1 ms movwf loops2 wai2 nop nop nop nop nop nop decfsz loops2, F ; 1 ms vorbei? goto wai2 ; nein, noch nicht decfsz loops, F ; 250 ms vorbei? goto wai ; nein, noch nicht return ; das Warten hat ein Ende ; ;************************************************************** ; ENDE ; ende end