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_rb and One button for different functions

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kmp84



Joined: 02 Feb 2010
Posts: 354

View user's profile Send private message

#int_rb and One button for different functions
PostPosted: Thu Aug 12, 2010 9:17 am     Reply with quote

Hi Friends!! Can anybody help me with example for #int_rb and #int_timer1 interrupts for making one button with different function? (push without holding ->increment var.count, push with holding 1-2second ->clear var. count)

Thanks before Smile
trirath



Joined: 14 Jun 2010
Posts: 20
Location: Pathunthanee Thailand

View user's profile Send private message

PostPosted: Wed Aug 25, 2010 3:44 am     Reply with quote

Let see example and you can modify. It work fine but may not be expert code.
Code:

#int_RB                         
void menu_isr() {
if(!input(PIN_B4)) RB_ready=1;
}
void main(void){
...

...
...

while(true){
 if(RB_ready){
   
     while(!input(PIN_B4) && (++timeout<350000)); //PRESS LONG APP 3 SECOND 
     beep(); //call Beep routine
                                if(input(PIN_B4))
                                {
                                          MENU=!MENU; // Menu is int1
                                          // Loop Menu if press not longer than 3 second
                            if(MENU==0){ //do something// } 
                            if(MENU==1){ //do something//}
                                                         
                                         
                                }
                                     
                           else {  //Press more then 3 second do this
                                   delay_ms(200);       
                               
                                         //do something//
                                       timeout=0;
                                }
               } //end else 
                   
                                      RB_ready=0;       
           }//end rB ready

 ...

...
}//end while
}//end main
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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