Reputation: 55
I have a switch button that is connected to RB1. This button acts as a reset but it needs to be pressed twice for it to work. If the second press happens after 500 ms (relative to the initial press), it will do nothing.
I think I should make use of timers or ccp module but I am not sure how to implement those. What do you suggest?
Edit (My ISR):
void interrupt ISR(void){
GIE = 0;
if(INTF){
INTF = 0;
if(reset_press == 0){
TMR1 = 0x0BDC; // counter starts counting at 0x0BDC (3036)
TMR1ON = 1; // Turns on Timer1 (T1CON reg)
}
reset_press++;
}
else if(TMR1IF==1){ // checks Timer1 interrupt flag
TMR1IF = 0; // clears interrupt flag
if(reset_press == 2){
reset_count(); // reset function
}
TMR1ON = 0; // Turns off Timer1 (T1CON reg)
reset_press = 0;
}
GIE = 1;
}
Upvotes: 1
Views: 115
Reputation: 2520
Upvotes: 1