Hey there,
I'm trying to code a portb change interrupt routine with DT's Inst Ints, but it does very weird stuff, and I can't find out why.
The setup:
PIC 16F876 @ 20 MHz
I have connected LEDs to the ports c0, c3, c4 and c5 to check what happens
The input switches are connected to ports b1-b4
The code looks something like this:
What happenes is the following:Code:define OSC 20 INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler RBC_INT, _PortBInterrupts, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM @ INT_ENABLE RBC_INT ; enable PortB change interrupts main: toggle led ' Toggles a LED that indicates if the program still runs :-) pause 250 low portc.0 low portc.3 low portc.4 low portc.5 goto main PortBInterrupts: if portb.1 = 1 then high input1 endif if portb.2 = 1 then high input2 endif if portb.3 = 1 then high input3 endif if portb.4 = 1 then high input4 endif @ INT_RETURN
If I press any button except of b4, nothing happens.
If I press only button b4 nothing happens
If I press b1 just before b4 then the LED according to b4 lits.
If i press any other button along with b4, the right LEDs light up.
It seems that button b4 is the mainswitch for all other buttons within the interrupt routine. Without b4 nothing happens.
So to verify the code I wrote something like this without interrupts:
With this code everything works fine. Every input lits the according output LED. So it must be a interrupt handling issue that makes the errors...Code:main: if portb.1 = 1 then high portc.0 if portb.2 = 1 then high portc.3 if portb.3 = 1 then high portc.4 if portb.4 = 1 then high portc.5 pause 250 low portc.0 low portc.3 low portc.4 low portc.5 goto main
any ideas?
Pls. Excuse my bad english, it's not my mother tongue...




Bookmarks