;****************************************************************************** ; * ; Filename: test_int.asm * ; Date: 23.04.2007 * ; File Version: 0.1 * ; * ; Author: Fuchs * ; Company:EL2 Labor * ; comment: ein einfaches Programm um einen externen Interrupt zu * ; demonstrieren. Priority ist deaktiviert. * ;****************************************************************************** ; * ; Files required: P18F4685.INC * ; * ;****************************************************************************** LIST P=18F4685 ;directive to define processor #include ;processor specific variable definitions ;****************************************************************************** ;Configuration bits ; Oscillator Selection: CONFIG OSC=IRCIO7 ;intern CONFIG WDT=OFF ;no Watchdog CONFIG CP0=OFF,CP1=OFF,CP2=OFF,CP3=OFF,CP4=OFF,CP5=OFF,CPB=OFF,CPD=OFF ;code protect off CONFIG WRT0=OFF,WRT1=OFF,WRT2=OFF,WRT3=OFF,WRT4=OFF,WRT5=OFF,WRTB=OFF,WRTC=OFF,WRTD=OFF CONFIG PBADEN=OFF ;Port A as I/O CONFIG BOREN=OFF CONFIG LVP=OFF ;low voltage programming ;****************************************************************************** ;Reset vector ORG 0x0000 goto Main ;go to start of main code ;****************************************************************************** ;High priority interrupt vector ; Wenn der Signalpegel an Pin RB0 (INT0) von GND auf 5V gezogen wird, dann ist ; ein Interrupt ausgelöst. Der Allgemeine/High-pritority Vektor beginnt bei ; 0x0008. Hier wird geprüft welcher Interrupt ausgelöst hat. Wenn es INT0 war, ; wird zur Interrupt-routine gesprungen ORG 0x0008 BTFSC INTCON,1 bra HighInt ;go to high priority interrupt routine ;****************************************************************************** ;High priority interrupt routine HighInt: ORG 0x0060 ; *** high priority interrupt code goes here *** bcf INTCON,1 ;Interruptflag von INT0 löschen btg LATC,2 ;Pin RC2 toggeln retfie FAST ;return from Interrupt (Wreg, Bsr und Status ;wird wiederhergestellt) ;****************************************************************************** ;Start of main program Init: movlw 0x90 ; enable INT0, global Interupts movwf INTCON movlw 0x70 ; maximale interne Frequenz 8MHz setzen movwf OSCCON movlw 0x07 movwf CMCON movlw 0x0F movwf ADCON1 clrf TRISC return Main: ; *** main code goes here *** ORG 0x0100 rcall Init ;Initialisieren Main_: goto Main_ return ;****************************************************************************** ;End of program END