Kbi Interrupt on MCF51JM doesnt work as expected

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Kbi Interrupt on MCF51JM doesnt work as expected

ソリューションへジャンプ
799件の閲覧回数
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 解決策
614件の閲覧回数
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 返信
615件の閲覧回数
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 件の賞賛
返信