Hello,
I'm using the E-Blocks EB006 Multiprogrammer with the PIC16F877-processor.
How can i trigger the interrupt for portB(B4-B7) only when B4-B7 gets from high to low?
Greetings,
W. Tulp
only interrupt when B4-B7 gets low
Moderator: Benj
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: only interrupt when B4-B7 gets low
Basically since PortB4 -B7 interrupts are non maskable, as soon as port B4 -B7 changes, a interrupt macro is called. Coding within that interrupt need to determin which port which has changed and determine if portsB4-B7 has gone from low to high or high to low.
I'm not saying this is the best way, but it should work the way you wanted.
If you got LED Eblock, then plug that into port C
Since I don't know what action you want to take when port goes from high to low,I have coded this so if:
Portb4 on interrupt goes from high to low then port C0 goes high.
Portb5 on interrupt goes from high to low then port C1 goes high.
Portb6 on interrupt goes from high to low then port C2 goes high.
Portb7 on interrupt goes from high to low then port C3 goes high.
When the relevant portC o/p goes high, it stays high. That can easily be changed. Instead of output high, you can use the coding in the main routine to do something when it detects the variable which has changed on interrupt 1 to 0 i.e. RB4_Hi2Low etc.
So all you need to do is substitute your own coding where you see each o/p goes high.
I will see if I can come up with a better solution with less variables.
I'm not saying this is the best way, but it should work the way you wanted.
If you got LED Eblock, then plug that into port C
Since I don't know what action you want to take when port goes from high to low,I have coded this so if:
Portb4 on interrupt goes from high to low then port C0 goes high.
Portb5 on interrupt goes from high to low then port C1 goes high.
Portb6 on interrupt goes from high to low then port C2 goes high.
Portb7 on interrupt goes from high to low then port C3 goes high.
When the relevant portC o/p goes high, it stays high. That can easily be changed. Instead of output high, you can use the coding in the main routine to do something when it detects the variable which has changed on interrupt 1 to 0 i.e. RB4_Hi2Low etc.
So all you need to do is substitute your own coding where you see each o/p goes high.
I will see if I can come up with a better solution with less variables.
- Attachments
-
- RB 4-7 interrupt port test.fcf
- (12 KiB) Downloaded 262 times
Martin
Re: only interrupt when B4-B7 gets low
Hello,
It's for an automotive turn left / right simulator.
At the moment the lights turned on and off with a loop.
When the switch left or right turned off the lights doesn't switch off directly. (the lights turned off at the end of the loop)
I want a solution that the lights directly turned off when the switch is turned to off.
This most be possible with a intterupt i thought, but how is it possible to break out the loop?
In the attachment the program at the moment. (flasherlight works when "contact" and "L" is on)
When "contact" is switched to off all lights directly need to turned off.
It's for an automotive turn left / right simulator.
At the moment the lights turned on and off with a loop.
When the switch left or right turned off the lights doesn't switch off directly. (the lights turned off at the end of the loop)
I want a solution that the lights directly turned off when the switch is turned to off.
This most be possible with a intterupt i thought, but how is it possible to break out the loop?
In the attachment the program at the moment. (flasherlight works when "contact" and "L" is on)
When "contact" is switched to off all lights directly need to turned off.