Dear All,
We are using TCA8418E with the AVR microcontroller in our application. For testing, a TI TCA8418E-EVM together with an ATMEL STK500 are being used at the moment.
The TCA8418E INT pin is connected to the AVR external interrupt pin INT0. We use 4X4 matrix keypad and the chip is configured as follows.
Write 0x01 = 0x19
/* Set registers to 4X4 keypad mode */
Write 0x1D = 0x0F
Write 0x1E = 0x0F
Write 0x1F = 0x00
/* Enable column debouncing */
Write 0x29 = 0x0F
Write 0x2A = 0x0F
Write 0x2B = 0x00
If a falling edge occurs on INT0, the interrupt is triggered and the steps below are followed.
(1) disable INT0
(2) read 0x02 to determine what event (pressed or released) causes interrupt
(3) read 0x04 to detemine what keys were pressed/released.
(4) save the key value or do some corresponding operations.
(5) read 0x04 again, if the value>0, go back to (2) and get another key value, otherwise, the keypad scan is completed.
(6) write 0x02 = 0xFF
(7) enable INT0
All these work correctly. But I have two issues related to our application.
(1) Every time entering the interrupt, only one event is detected, i.e., the register 0x03 would always be read as 01. If the user presses a series of keys, how can we detect all the events while calling the interrupt routine just once?
PS, when the chip was not working in the interrupt mode, we can actually see all events have been put in the FIFO and the register 0x03 is read as the number of key events occurred. However, in the interrupt mode, as we immediately read the register 0x04, the FIFO does not work as expected to save all events. Any suggestions?
(2) If the user pressed one key and hold it for a period of time, say 5s, how can we approximately check whether this key has been pressed for such a period of time?
Many thanks.
Trevor