Kbi Interrupt on MCF51JM doesnt work as expected

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

Kbi Interrupt on MCF51JM doesnt work as expected

Jump to solution
625 Views
ralu
Contributor III

I am trying to detect falling edges on input kbi pins.

Problem is, that once one falling edge is detected, second edge detection on another pin (also kbi enabled) does not work and interrupt get missed..

If there is only one pin low at time then each interrupt on any pin is correctly detected, and processed.

 

My solution is now that once interrupt happens, i change value of  KBI1 Interrupt Edge Select Register (KBI1ES),  This way any change on any pin always raises interrupt (falling or raising edge)

 

Since this looks more like hack that solution, can somebody tell me if i am doing something wrong and if my findings are correct.

 

Luka

Labels (1)
0 Kudos
1 Solution
440 Views
TomE
Specialist II

Have a look at 'Figure 9-2. Port Interrupt Block Diagram" in the Reference Manual. That explains how it is wired.

This is a KEYBOARD input port, so it is only meant for detecting single edges on one of the input pins at a time.

To do what you want there are two choices - flip the polarity like you're doing or disable that pin with the KBIPEn bit. The problem there is that you probably want to re-enable the interrupt when the pin changes state again, and the easiest way to do that is to do what you're doing - flip the edge.

If you get two pins changing close together you'll have to have some pretty smart code so it doesn't lock up or lose interrupts.

If the pins aren't changing all that often (and if you don't need microsecond-level timing) it might be simpler to just poll the pins from a timer interrupt or from your main event loop and detect changes in software.

If you do want fully independent interrupt capability and nanosecond-level timing you're better off using the TPM to capture the input times and generate interrupts.

Tom

View solution in original post

0 Kudos
1 Reply
441 Views
TomE
Specialist II

Have a look at 'Figure 9-2. Port Interrupt Block Diagram" in the Reference Manual. That explains how it is wired.

This is a KEYBOARD input port, so it is only meant for detecting single edges on one of the input pins at a time.

To do what you want there are two choices - flip the polarity like you're doing or disable that pin with the KBIPEn bit. The problem there is that you probably want to re-enable the interrupt when the pin changes state again, and the easiest way to do that is to do what you're doing - flip the edge.

If you get two pins changing close together you'll have to have some pretty smart code so it doesn't lock up or lose interrupts.

If the pins aren't changing all that often (and if you don't need microsecond-level timing) it might be simpler to just poll the pins from a timer interrupt or from your main event loop and detect changes in software.

If you do want fully independent interrupt capability and nanosecond-level timing you're better off using the TPM to capture the input times and generate interrupts.

Tom

0 Kudos