asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Dec 06, 2011 2:42 pm |
|
|
here is code that INITS for edge driven ints on TWO different B port lines
and sorts out what to do for either-- in the ISR
it maybe can be done better - but is known to work as as an EXAMPLE
| Code: |
void ISR_INIT(void){
byte junk;
EXT_INT_EDGE(H_TO_L); // on B7 or B5
clear_interrupt(INT_RB);
enable_interrupts(INT_RB);
junk=input_b();
enable_interrupts(global);
junk=input_b();
}
#INT_RB
void bintisr(){
byte junk;
if (!input_state(PIN_B7)) { // if LOW
bext=1; // global ext flag that INT was called
if (armed) { // external arming for INT service
output_low(pin_d0); // no arms closed
set_pwm1_duty(0);
}
}
// check for APC crash inlet
if (!input_state(PIN_B5)) { // if held LOW
output_low(pin_d1);
set_pwm2_duty(0); // no ILED
illrun=0;
output_low(PIN_D2); // kill servo power
servogo=0;
}
junk=input_b(); // clr int for sure before leaving
}
|
i set global vars and make sure that if BOTH monitored pins have changed - i likely won't miss either one. The SECOND test on pin_B5 actually ends up effectively doing what the first conditional does selectively - since setting 0 as PWM2 at 0 duty kills power to the circuitry being selectively controlled by pin B7 anyway .
once again - i am counting on the really clever programmers here to help me do this better too  |
|