Kbi Interrupt on MCF51JM doesnt work as expected

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Kbi Interrupt on MCF51JM doesnt work as expected

跳至解决方案
795 次查看
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

标签 (1)
0 项奖励
回复
1 解答
610 次查看
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 项奖励
回复
1 回复
611 次查看
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 项奖励
回复