HC08 Keyboard interrput question

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

HC08 Keyboard interrput question

1,931 Views
aurora
Contributor I
I am using a MC68HC908QY4A MCU for a handheld device. There are 3 switches A, B, and C. A and B are momentary push button switches, C is a toggle on/off switch.  I have setup a keyboard interrupt service routine. The keyboard triggering sensitivity bit is set to falling edge only for all 3 switches. Right now, whenever switch C is at LOW, switch A and B are disabled. Is there a way to have switch A and B are active when switch C at LOW state.
Labels (1)
0 Kudos
5 Replies

396 Views
tonyp
Senior Contributor II

MODEK bit should be zero to accept only edges, not levels and edgesOnce inside the handler, acknowledge the interrupt (ACKK) so that another interrupt can be acceptedWhen any of the remaining pins goes low next, it should fire the interrupt again (even while the "C" pin is still low).

 

But, (except for getting out of STOP mode), I wouldn't use keyboard interrupts at all, at least for the toggle switch whose state can be read easily with a BRCLR/BRSET instruction (assembly).

Message Edited by tonyp on 2009-03-23 08:53 PM
0 Kudos

396 Views
aurora
Contributor I
Thanks tonyp. Switch C is for getting the unit out of STOP mode. I have initialized KBSCR = 04H, but it does not accepted another interrupt when switch C is LOW.
0 Kudos

396 Views
bigmac
Specialist III

Hello,

 

Since all three switches will be set up to cause an interrupt on a falling edge, the inputs are effectively NANDed together before being fed to the edge sensitive interrupt circuitry within the MCU. This means that, while any one input remains low, no further edges can be generated - the logic level at the output of the combining gate will be continuously high.

 

At this point, the particular active switch should be determined, and the interrupt disabled for that input, to allow further interrupts to occur for the other inputs. The switch states would then need to be peridically tested, to determine when each individual interrupt should be re-enabled. For a mechanical switch, the process will also need to implement a suitable debounce delay, to prevent multiple interrupts occurring for a single switch closure.

 

For the device you are using, it is possible to alter individual inputs for positive edge interrupt, which might at first appear to solve the problem for the toggle switch input. However, there will be a serious side effect - the internal pullup then becomes a pulldown, and the pullup/down cannot be disabled during KBI operation. So any external pullup resistor you might provide would conflict with the internal pulldown.

 

As Tony P suggested, the simplest solution may be to periodically poll the state of the toggle switch (from within the main program loop) for both on and off states. For a hand-held (presumably battery operated) equipment, another issue may be the continuous current drawn by the internal pullup whilst the toggle switch remains active.  The pullup may need to be periodically enabled for a short period only, just prior to polling the switch state.

 

Regards,

Mac

Message Edited by bigmac on 2009-03-24 01:04 PM
0 Kudos

396 Views
peg
Senior Contributor IV

Hello,

 

There is good reason these are called keyboard interrupt ports.

The reason is there usage is limited outside the normal case of a normal keypad matrix where more than one key pressed at a time is considered illegal. I believe Tony's description is wrong. No matter what the MODEK bit is set to, it is still necessary to have all enable pins at the inactive state to detect the next edge/level change. The MODEK bit only allows an interrupt to be acknowledged and cleared while the pin is still in the active state. The HC08 manuals are unclear on this, the S08 manuals are much clearer. I believe all work the same in this regard.

 

The way to get around this is to disable the active pin after the interrupt has occured, this allows other to be detected while the first is still active. One problem is that now if it goes off and back on again very quickly will you have re-enabled it in time?

 

Another issue is as the interrupt is common and there is no latch, if two go active very close together you may not know which one was first.

 

Having said that I have made use of three of the KBI port pins in an application where they are connected to off board sensors. I have been able to do this because I know ahead of time which pin I am expecting to go active and do not care if the other ones go active out of sequence.

 

So it is still useful, but not as useful as you may first imagine given the above limitations.

 

 

0 Kudos

396 Views
aurora
Contributor I

Thanks for all the advices. I have disabled switch C interrupt after it goes to LOW, then Switch A and B are function as normal (active). Whenever switch C is LOW, the unit never goes into STOP mode. There is a 2 minutes idle time before the unit enters STOP mode, “C” returns to HIGH state and keyboard interrupt is enabled during idle time (before goes to STOP mode).

 

Thanks to all,

 

Aurora

0 Kudos