Hallo,
Ich hab noch ein bischen Totzeit eingebaut, dammit das ein - ausschalten auch wirklich "smooth" funktioniert und einen Register für den Zustand im PortB (Das direkte auslesen des PortB funktioniert aus irgendeinem Grund nicht).
Vielleicht steht ja jemand vor dem selben Problem, dann kann er ja den Code hier ganz gut gebrauchen...
Code:
CODE
HighInt:
btfsc test, 1 ;Led invertieren
goto aus
goto ein
aus ;Led aus
call totzeit ;Damit das ganze nicht so empfindlich ist :)
bcf PORTB,1
bcf test,1
bcf INTCON,RBIF ;Interruptflag löschen
retfie
ein ;Led ein
call totzeit ;Damit das ganze nicht so empfindlich ist :)
bsf test,1
bsf PORTB,1
bcf INTCON,RBIF ;Interruptflag löschen
retfie
;******************************************************************************
;Low priority interrupt routine
; The low priority interrupt code is placed here.
; This code can be removed if low priority interrupts are not used.
LowInt:
movff STATUS,STATUS_TEMP ;save STATUS register
movff WREG,WREG_TEMP ;save working register
movff BSR,BSR_TEMP ;save BSR register
; *** low priority interrupt code goes here ***
movff BSR_TEMP,BSR ;restore BSR register
movff WREG_TEMP,WREG ;restore working register
movff STATUS_TEMP,STATUS ;restore STATUS register
retfie
;******************************************************************************
;Start of main program
; The main program code is placed here.
;**************************************************************
; das Hauptprogramm
Init
; RB0-Interrupt einstellen
movlw b'11111101'
movwf TRISB
movlw b'00000000'
movwf PORTB
bcf INTCON2,RBPU ;Interne Pullups aktivieren
clrf INTCON ;ganzes INTCON löschen
bsf INTCON, RBIE ;enables PortB Interrupts
bsf INTCON, GIE ;global interrupt enable
return
totzeit
movlw 0xFF
movwf bigcount
bigloop
decfsz bigcount
goto weiterloop
return
weiterloop
movlw 0xFF
movwf smallcount
smallloop
decfsz smallcount
goto smallloop
goto bigloop
Main:
call Init
loop
goto loop
; *** main code goes here ***
;******************************************************************************
;End of program
END
Lesezeichen