;-------------------TMR1 COUNTER-MODE banksel T1CON ;bank 0 CLRF T1CON ;Bit7:6 "00" TMR1 clock source is Fosc/4 bcf T1CON,T1CKPS1 ;Bit5:4 "00" Prescaler 1:1 bcf T1CON,T1CKPS0 ; ;Bit3=0 LP Oscillator is OFF bsf T1CON,NOT_T1SYNC;Bit2=1 ->??? ignored (because internal osc. is in use) bsf T1CON,TMR1ON ;Bit0=1 TMR 1 ENABLED ; ;-------------------TIMER 1 GATE CONTROL bank 0 ; banksel PIE1 ;bank1 ; bcf PIE1,TMR1GIE ;TMR1 Gate Interrupt Disabled ; banksel PIR1 ;bank0 ; clrf PIR1 ; bcf PIR1,TMR1GIF ;Bit7=1 Interupt is pending "austehend" clrf T1GCON bsf T1GCON,TMR1GE ;Bit7=1 TMR1 Gate is ENABLED bsf T1GCON,T1GPOL ;Bit6=1 TMR1 COUNTS when gate is HIGH bcf T1GCON,T1GTM ;Bit5=0 Toglemode disabled bsf T1GCON,T1GSPM ;Bit4=1 Gate single pulse ENABLED bcf T1GCON,T1GGO ;Bit3=1 Single pulse WAITING FOR AN EDGE ;Bit2 Gate current state ; bcf T1GCON,T1GSS1 ;Bit1:0 "01" Gate source is TMR0 OVERFLOW ; bsf T1GCON,T1GSS0 ;Bit0=1 ; bcf T1GCON,T1GSS1 ;Bit1:0 "00" Gate source is TMR1- bcf T1GCON,T1GSS0 ;Bit0=0 Gate-Pin "T1G" -> RB0 ; GOTO Main ;****************************************************************************** Main clrf TMR1L clrf TMR1H bsf T1GCON,T1GGO ;Bit3 set by sofware cleared by hardware Main_Loop btfsc T1GCON,T1GGO ;=1 Flankenwechsel Gatepuls H->l? GOTO Main_Loop ;Nein, weiter warten CALL OutTimer1 ;JA, Zählerstand ausgeben CALL OutT1GCON ;Register zur Kontrolle ausgeben CALL OutPORTB movlw d'2' ;Ablesepause 0,2s call Delay100ms GOTO Main ;******************************************************************************