HC08: keyboard interrupt problem

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

HC08: keyboard interrupt problem

跳至解决方案
2,725 次查看
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,273 次查看
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,274 次查看
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,273 次查看
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 项奖励
回复