AnsweredAssumed Answered

Keyboard interrupts and timer interrupt used as debounce - question

Question asked by Russell Sher on Feb 4, 2013
Latest reply on Feb 15, 2013 by bigmac

Hi

I am using the keyboard interrupt and was intending to use the RTC timer interrupt for debounce counting. ( MCU is S08QE128)

Further to this, I may also need to measure the length of time that the key is being held down in certain parts of the code.

The problem is of course that during the servicing of the key board interrupt, the RTC interrupt does not get serviced - and my debounce counter does not count - so the routine hangs in one place.

As I understand that nesting interrupts is not advisable (i.e. don't enabe the global interrupt enable within the keyboard ISR)

So what might a better approach be?

I have though of the following:

When the Keyboard ISR gets called :

1. Set a flag (e.g. key_x_pressed)

2 Immediately exit the Keyboard ISR

3 Disable the keyboard interrupt

4. Use the RTC to wait for a debounce period having used the flag that was set above to indicate that a debounce is required

OR if my code requires - wait while the key is held down such as:

While(key_down_count)

{

// key_down_count is a volatile variable decremented in the RTC ISR.

}

 

Any comments out there?

thanks

Russell

Outcomes