list p=16F628a #include "p16f628a.inc" ; De definities __CONFIG _CP_OFF & _BODEN_OFF & _DATA_CP_OFF & _PWRTE_ON & _WDT_OFF & _LVP_OFF & _MCLRE_ON & _INTRC_OSC_NOCLKOUT teller EQU 20h sleept1 EQU 21h sleept2 EQU 22h tempw EQU 23h #define PULSE PORTB,0 #define SHUTTER PORTB,1 #define LED PORTB,2 ; Begin prog ORG 00h GOTO init ; Begin Interrupt ORG 04h MOVWF tempw ; 1 CALL sleep993usec ; +2 +993 NOP NOP NOP ; + 3 = 999 CLRF teller ; en nu 1000 usec ; 1 msec is nu om, nu moeten we gaan tellen postel INCF teller ; 1 BTFSC PULSE ; 1 GOTO postel ; 2 -> totaal 4 us BCF INTCON, INTF ; bit 1 MOVFW tempw RETFIE ; Init init CLRF PORTB BCF STATUS, RP1 BSF STATUS, RP0 CLRF TRISB ; Portb wordt output BSF PULSE ; Uitzondering, pulse ingang CLRF INTCON BSF OPTION_REG, INTEDG ; rising edge BSF INTCON, INTE ; enable INT interrupt BSF INTCON, GIE ; enable alle interrupts BCF STATUS, RP0 CLRF teller; begin MOVFW teller BSF PORTB,3 BTFSC teller,7 GOTO aan GOTO uit aan BSF LED BSF SHUTTER GOTO begin uit BCF LED BCF SHUTTER GOTO begin sleep993usec MOVLW d'198' ; 1 MOVWF sleept1 ; 1 sleep993in NOP ; \ NOP ; | 5 msec DECFSZ sleept1, 1 ; | GOTO sleep993in ; / RETURN ; END