Also, da die Frage, wieso das nicht geht, mich auch interessiert, hab ich dein Programm mal durch den Simulator vom MPLab gejagt. Hier sind die Fehler:
Code:
bsf INTCON, GIE ; Interupt generell erlauben
Der Fehler liegt in dieser Zeile. Du darfst in einem Interrupt den GIE NICHT setzten, bevor du den Flag gelöscht hast, weil ansonsten sofort wieder ein Interrupt ausgelöst wird (und du wieder an den Anfang des Interrupts springst --> Unendlichschleife). Überhaupt, wieso setzt du ihn manuell? Der Befehl retfie macht das für dich automatisch
.
Ansonsten, ziehst du die Pins gegen GND zum Auslösen des Interrupts? Weil dann musst du die internen Pull-Ups des µC einschalten (oder aber die Pins exterm mit Winderständen nach Vcc ziehen). Ach, ja, nur die Pins RB 4-7 haben die Möglichkeit einen Interrupt auszulösen.
MfG
Mobius
P.S.: Hab das Projekt, mit dem ich es getestet habe, als zip beigefügt. Der Stimulus funktioniert nur bedingt (Toggle, also es invertiert den besagten Pin), weil ich wegen den Einschränkungen des Simulators (Weak pull-ups on ports not implemented) ein nach-GND-ziehen nicht simulieren kann.
€dit: für alle, die die zip nicht herunterladen wollen, hier ist die src 
Code:
;******************************************************************************
; This file is a basic template for assembly code for a PIC18F2550. Copy *
; this file into your project directory and modify or add to it as needed. *
; *
; The PIC18FXXXX architecture allows two interrupt configurations. This *
; template code is written for priority interrupt levels and the IPEN bit *
; in the RCON register must be set to enable priority levels. If IPEN is *
; left in its default zero state, only the interrupt vector at 0x008 will *
; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not *
; be needed. *
; *
; Refer to the MPASM User's Guide for additional information on the *
; features of the assembler. *
; *
; Refer to the PIC18Fx455/x550 Data Sheet for additional *
; information on the architecture and instruction set. *
; *
;******************************************************************************
; *
; Filename: *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
;******************************************************************************
LIST P=18F2550 ;directive to define processor
#include <P18F2550.INC> ;processor specific variable definitions
;******************************************************************************
;Configuration bits
; The __CONFIG directive defines configuration data within the .ASM file.
; The labels following the directive are defined in the P18F2550.INC file.
; The PIC18FX525/X620 Data Sheet explains the functions of the
; configuration bits.
__CONFIG _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_1_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H & _FCMEM_ON_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_OFF_2L & _BOR_OFF_2L & _BORV_46_2L & _VREGEN_OFF_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_1_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_OFF_3H
__CONFIG _CONFIG4L, _DEBUG_OFF_4L & _LVP_OFF_4L & _STVREN_OFF_4L
__CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L
__CONFIG _CONFIG5H, _CPB_OFF_5H
__CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L
__CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H & _WRTD_OFF_6H
__CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L
__CONFIG _CONFIG7H, _EBTRB_OFF_7H & _DEVID1 & _IDLOC0
;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.
ORG 0x0000
goto Main ;go to start of main code
;******************************************************************************
;High priority interrupt vector
; This code will start executing when a high priority interrupt occurs or
; when any interrupt occurs if interrupt priorities are not enabled.
ORG 0x0008
bra HighInt ;go to high priority interrupt routine
;******************************************************************************
;High priority interrupt routine
; The high priority interrupt code is placed here to avoid conflicting with
; the low priority interrupt vector.
HighInt:
btfsc PORTB, 1 ;Led invertieren
goto aus
goto ein
aus ;Led aus
bcf PORTB,1
; bsf INTCON, GIE ; Fehler, damit löst du einen erneuten Interrupt aus.
bcf INTCON,RBIF
retfie
ein ;Led ein
bsf PORTB,1
; bsf INTCON, GIE ; Fehler, damit löst du einen erneuten Interrupt aus.
bcf INTCON,RBIF
retfie
;******************************************************************************
;Start of main program
; The main program code is placed here.
Init
; RB0-Interrupt einstellen
movlw b'11111101'
movwf TRISB
bcf INTCON2,RBPU ;Interne Pullups aktivieren
clrf INTCON ; ist das gleiche wie movlw 0x00 und anschließend movfw INTCON
bsf INTCON, RBIE
bsf INTCON, GIE
return
Main:
call Init
loop
goto loop
;******************************************************************************
;End of program
END
Lesezeichen