EmbeddedRelated.com
Forums

Port H interrupt on HCS12

Started by deaninkc March 6, 2004
I've got an Axiom 256 board I'm playing with and am having a problem
getting an interrupt to work on Port H the way I want it to. I've got
a passive keypad hooked to it 4 pins configured as output and 4 as
input. When a key is hit it ties one of the input and output pins
together. If I used the polled method, turn on one output pin and
then read it to see if any of the input pins are on, then it works
fine. When I turn on the interrupt set all the output pins high and
press a key, I get an interrupt as expected and when I read it I get
the input pin high like I would expect, put when I turn around and
poll it to see when output colunm is connected, I get nothing. Its
like the output is turned off when you are in interrupt mode. I tried
using polled mode when the interrupt flags are set and have no luck.
Anyone have any experiance with this and know what my problem might
be?



At 14:39 06/03/2004 +0000, you wrote:
>I've got an Axiom 256 board I'm playing with and am having a problem
>getting an interrupt to work on Port H the way I want it to. I've got
>a passive keypad hooked to it 4 pins configured as output and 4 as
>input. When a key is hit it ties one of the input and output pins
>together. If I used the polled method, turn on one output pin and
>then read it to see if any of the input pins are on, then it works
>fine. When I turn on the interrupt set all the output pins high and
>press a key, I get an interrupt as expected and when I read it I get
>the input pin high like I would expect, put when I turn around and
>poll it to see when output colunm is connected, I get nothing. Its
>like the output is turned off when you are in interrupt mode. I tried
>using polled mode when the interrupt flags are set and have no luck.
>Anyone have any experiance with this and know what my problem might
>be?

Did you account for debouncing?

Debouncing is an electrical phenomenon caused by mechanical switches. In
this phenomenon the voltage will alternate between the two voltages (the
old voltage and the new voltage) after pressing the keypad, which will last
for some 1mSEC - 100mSEC before stabilizing on the new voltage.

Maybe it is possible you are suffering from such debouncing. There are
several ways to overcome the debouncing. The simplest one is to perform a
delay in software to let the inputs stabilize before reading their state.

Hope this helps,
Doron
Nohau Corporation
HC12 In-Circuit Emulators
www.nohau.com/emul12pc.html



I've got debounce logic in there, it works fine in polled mode. I
can't seem to get the output configured pins to work when the
interrupt is set even if it is only set on 4 of the pins. I'm writing
a program to output to some LED's to test the theory. I may be stuck
using polled mode when using a keypad, but that will complicate my
code and screw up my timing.

Dean

--- In , Doron Fael <doronf@n...> wrote:
> At 14:39 06/03/2004 +0000, you wrote:
> >I've got an Axiom 256 board I'm playing with and am having a
problem
> >getting an interrupt to work on Port H the way I want it to. I've
got
> >a passive keypad hooked to it 4 pins configured as output and 4 as
> >input. When a key is hit it ties one of the input and output pins
> >together. If I used the polled method, turn on one output pin and
> >then read it to see if any of the input pins are on, then it works
> >fine. When I turn on the interrupt set all the output pins high and
> >press a key, I get an interrupt as expected and when I read it I
get
> >the input pin high like I would expect, put when I turn around and
> >poll it to see when output colunm is connected, I get nothing. Its
> >like the output is turned off when you are in interrupt mode. I
tried
> >using polled mode when the interrupt flags are set and have no
luck.
> >Anyone have any experiance with this and know what my problem might
> >be?
>
> Did you account for debouncing?
>
> Debouncing is an electrical phenomenon caused by mechanical
switches. In
> this phenomenon the voltage will alternate between the two voltages
(the
> old voltage and the new voltage) after pressing the keypad, which
will last
> for some 1mSEC - 100mSEC before stabilizing on the new voltage.
>
> Maybe it is possible you are suffering from such debouncing. There
are
> several ways to overcome the debouncing. The simplest one is to
perform a
> delay in software to let the inputs stabilize before reading their
state.
>
> Hope this helps,
> Doron
> Nohau Corporation
> HC12 In-Circuit Emulators
> www.nohau.com/emul12pc.html >