CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

INT ext
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Dec 06, 2011 2:42 pm     Reply with quote

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 Very Happy Arrow
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group