HC08: keyboard interrupt problem

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

HC08: keyboard interrupt problem

ソリューションへジャンプ
2,723件の閲覧回数
hasan
Contributor I
hi people,
I have the DEMO9S08QG8 demoboard. i am trying to enable an output through the KBI modul with CW..
when i push the switch, the interrupt occurs. the interrupt routine is executed. but after the RTI instruction is executed, it jumps to the beginning of the interrupt routine, not back to the mainloop...
so it gets stuck inside the interrupt routine...
 
Any idea what the problem is?

Message Edited by CrasyCat on 2007-04-13 02:22 PM

ラベル(1)
タグ(1)
0 件の賞賛
返信
1 解決策
1,271件の閲覧回数
bigmac
Specialist III
Hello Hasan,
 
It sounds like you may not be clearing the interrupt flag before exiting the ISR.  You need to write a 1 to the KBACK bit within KBISC register.
 
Another possibility is that you have selected both edge and level interrupt by setting the KBMOD bit to 1.  This would mean that interrupts could repeatedly occur while the key remained pressed (or released if the wrong polarity were selected).
 
Yet another possibility is that you do not allow for key bounce, and the ISR is re-entered a number of times.  A satisfactory way of allowing for de-bounce would be to disable further interrupts for the particular key, before leaving the ISR.  Then, within the main loop, allow for a 50-100 millisecond delay before re-enabling interrupts for the key that was pressed.  Because of key bounce, you might get interrupts occurring as the key is released, as well as when pressed, but this would depend on the switch characteristics.
 
Regards,
Mac
 

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,272件の閲覧回数
bigmac
Specialist III
Hello Hasan,
 
It sounds like you may not be clearing the interrupt flag before exiting the ISR.  You need to write a 1 to the KBACK bit within KBISC register.
 
Another possibility is that you have selected both edge and level interrupt by setting the KBMOD bit to 1.  This would mean that interrupts could repeatedly occur while the key remained pressed (or released if the wrong polarity were selected).
 
Yet another possibility is that you do not allow for key bounce, and the ISR is re-entered a number of times.  A satisfactory way of allowing for de-bounce would be to disable further interrupts for the particular key, before leaving the ISR.  Then, within the main loop, allow for a 50-100 millisecond delay before re-enabling interrupts for the key that was pressed.  Because of key bounce, you might get interrupts occurring as the key is released, as well as when pressed, but this would depend on the switch characteristics.
 
Regards,
Mac
 
0 件の賞賛
返信
1,271件の閲覧回数
hasan
Contributor I
Hi Mac,
Thanks for your help. The problem was the KBACK bit. And now it works.
Well.. I think I have got much to learn...
Regards,
Hasan
0 件の賞賛
返信