KBI - how to ensure that no edge sensitive interrupts are missed?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KBI - how to ensure that no edge sensitive interrupts are missed?

662 Views
mjbcswitzerland
Specialist V

Hi All

The larger KE devices include the KBI (Keyboard Interrupts) which allows up to 64 inputs to be configured as rising or falling edge interrupts (or also level sensitive). There are two KBIs, each responsible for 32 of the inputs each).

The problem is that it doesn't look possible to guarantee that there are no potential edge interrupt loses due to the interrupt clearing mechanism.

When any one of the inputs triggers the interrupt the interrupt flag is set and the interrupt handler called. This handler can see which one or more inputs triggered by reading KBIx_SP, where there is flag for each source. This means that the interrupt routine can then dispatch a user handler specifically for the input, or inputs, that triggered.

The difficulty arises due to the fact that the input flags need to be reset by writing the RSTKBSP bit in the status register, which resets all set flags.

Consider the sequence:

1. read the input status flags (eg. KBIx_P0 is set so we known that this triggered and we can handle it during further steps)

2. reset flags

3. handle flagged inputs from 1.

Normally this works fine but what happens when a further input triggers between the actions 1. and 2. ? It means that the new input (which wasn't read in 1. because it was not yet ready) is reset by 2 and the result is that the interrupt handler doesn't know about this interrupt.

The new input event can set the interrupt flag again and this causes the interrupt to be re-entered, but this time there is no source flag showing why it came. It could be assumed that the flag was lost and so all input states need to be 'manually' checked to try to identify which it could be but this also fails if there is another one also that happens to fire at the same time because then this other one looks to be the only one).

After studing the KBI user's manual I don't see any mechanism built in to it that allows edges to be reliably detected in all instances without the need to check all input states each time there is an interrupt (the same as the more simple KBI in the smaller devices which doesn't have the KBIx_SP register), but this would mean that the KBIx_SP register is redundant to a degree because it can't be fully trusted.

I see that the KBI has been used in 8 bit parts for some time so I suppose that such a problem would be well understood. Is there however some inbuilt mechanism that protects against such flag loss which ensures that it can be used effectively?

Regards

Mark

Labels (1)
Tags (4)
0 Kudos
1 Reply

346 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Mark Butcher,

Firstly, I consider that the KBI will miss the next interrupt if it comes between the action 1 and 2 just as you stated previously,

however we strongly don't recommend to use the KBI module to figure out the edge or lever chanage if the similar phenomenon happens constantly,

and we'd like to suggest that try other modules like FTM to instead of the KBI.

I'll also contact with AE team for checking whether the KBI has some inbuilt mechanism that protects against such flag loss which ensures that it can be used effectively.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos