SPRUIE9D May 2017 – May 2024 DRA74P , DRA75P , DRA76P , DRA77P
As described in the previous section, each functional mode is associated with a timer value. Depending on the selected mode, the keyboard controller timer is loaded with the corresponding value as set in the related registers:
Table 30-8 summarizes the values of the keyboard controller timer.
Timer Value | Associated Register Field | Description |
---|---|---|
Debouncing time | KBD_DEBOUNCINGTIME[5:0] DEBOUNCING_VALUE | To remove the effects of glitches when an event occurs on the keyboard, the controller waits for a debouncing period before taking a snapshot of the current state on the keyboard matrix. The timer is loaded with the debouncing time value after each detected event on the keyboard matrix. An event interrupt is generated after this delay. |
Long-key time | KBD_KEYLONGTIME[11:0] LONG_KEY_VALUE | This is the delay before generating a long-key interrupt after an event interrupt. If the long-key mode is selected, the timer is loaded with the long-key time value after an event interrupt is generated. |
In repeat mode, the timer is reloaded with the same value after a long-key interrupt, and starts to count down again. | ||
Long-key time-out | KBD_TIMEOUT[15:0] TIMEOUT_VALUE | The timer is loaded with the time-out value and then a long-key interrupt is generated and starts to count down. When it reaches 0, a time-out interrupt is generated and the keyboard controller returns to its IDLE state. This long-key time-out does not work in repeat mode. |
Empty key time-out | KBD_TIMEOUT[15:0] TIMEOUT_VALUE | The time-out interrupt occurs if no key is pressed during this delay. The keyboard controller then returns to IDLE state. |
The timer countdown period depends on three factors:
The period is calculated as follows:
Tperiod = (Tvalue + 1) x 2PTV + 1 x Tclk
Where:
Tvalue is the value stored in the KBD_DEBOUNCINGTIME, KBD_KEYLONGTIME, or KBD_TIMEOUT register.
PTV is the value of the KBD_CTRL[4:2] PTV bit field.
Tclk is the period of the 32-kHz functional clock; that is, 31.25 µs or other (depending wheather the 32K oscillator or the SYSCLK1/610 clock is selected as source).
The KBD_CTRL[4:2] PTV bit field determines the division factor of the timer clock. Table 30-9 lists the divider rates.
KBD_CTRL[4:2] PTV Value | Divisor |
---|---|
0 | 2 |
1 | 4 |
2 | 8 |
3 | 16 |
4 | 32 |
5 | 64 |
6 | 128 |
7 | 256 |
The timer minimum period is 62.5 µs; its maximum period is 524.288 seconds.
To prevent undefined results, the KBD_CTRL[4:2] PTV bit field must not be changed when the timer is running.
The timer value registers (KBD_DEBOUNCINGTIME, KBD_KEYLONGTIME, and KBD_TIMEOUT) can be updated at any time, whether or not the timer is running. Nevertheless, the timer is updated only on the fly for the long-key time value. The new debouncing and time-out values are loaded only on the next load. Depending on the updated register, two cases can occur:
Regardless of the timer state (stopped, counting down any of the values previously described, etc.), when a new event occurs on the keyboard, the timer is stopped and loaded with the debouncing time value. It then starts counting down.