I'm using a pic16f627a, i have a switch connected to the External interrupt INT, I want to debounce that using a delay of ~50ms using the Timer0 interrupt.
How do I do that?
From what I understand, when the external interrupt is generated, in the interrupt service routine, I should
1. Disable the external interrupt by clearing INTE
2.I should set a counter equivalent to that 50ms
3. I set a debounced flag to 0.
4. In the Timer0 interrupt routine, I decrement that counter, and then if it's 0, then I set the debounced flag to 1.
5. Back in the external interrupt routine, I wait until the debounced flag is set to 1
6. If it's 1, then I do whatever I want to do(light on led or something), then clear the the INTF flag
7. Reenable the interrupt by setting INTE
Is that correct?
Somehow this seems logical to me, but it doesn't work, it just seems to be stuck somewhere, could someone please help? :roll:
How do I do that?
From what I understand, when the external interrupt is generated, in the interrupt service routine, I should
1. Disable the external interrupt by clearing INTE
2.I should set a counter equivalent to that 50ms
3. I set a debounced flag to 0.
4. In the Timer0 interrupt routine, I decrement that counter, and then if it's 0, then I set the debounced flag to 1.
5. Back in the external interrupt routine, I wait until the debounced flag is set to 1
6. If it's 1, then I do whatever I want to do(light on led or something), then clear the the INTF flag
7. Reenable the interrupt by setting INTE
Is that correct?
Somehow this seems logical to me, but it doesn't work, it just seems to be stuck somewhere, could someone please help? :roll: