HC08: keyboard interrupt problem

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

HC08: keyboard interrupt problem

Jump to solution
2,080 Views
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

Labels (1)
Tags (1)
0 Kudos
1 Solution
628 Views
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
 

View solution in original post

0 Kudos
2 Replies
629 Views
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 Kudos
628 Views
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 Kudos