AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi,

im learning how to use the AT91RM9200..right now im trying to tackle
the AIC. iv set everyhting up, earmarking PIOA0 for an external
interrupt through a switch connected to it, so that theoretically
whenever the switch is pressed, an interrupt is generated that sends a
string via the debug port to hyperterminal.

everythings fine, but when i press the switch once, i get 2
interrupts...one whenthe switch is down, the other when i release
it..ive tried this in all modes, level sensitive, edge sensitive, high
level, positive edge, etc, all possible ones..
i dont suppose its due to a contact bounce, since im getting symmetric
interrupts like this..im using the exact libraries provided by atmel
(irq_pio.s and irq.mac)..

kindly advise what could be going wrong..
Thanx in anticipation

Mayank


Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(
On 10 Jan 2005 04:37:28 -0800, "Mayank Kaushik"

Quoted text here. Click to load it

You need to read the data sheet more closely.  The PIO pins on this
microcontroller only have an "input change" interrupt.  The only
choice you have is to disable the interrupt for a particular input or
to enable it.  If it is enabled you will get an interrupt every time
the input changes, and that means once when you press the switch and
once when you release it.

That's the way the part works, and there is no way to change it.

--
Jack Klein
Home: http://JK-Technology.Com
We've slightly trimmed the long signature. Click to see the full one.
Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(
:-O oh boy i didnt know that!

Thanx a ton, jack..im an undergrad student, this is my first
microcontroller..ive had lots of help from you and other guys at this
group, thanx a ton!

regards
Mayank


Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(
or i could put a toggle flip-flop between the switch and the pio
pin..hmm, that should work


Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(

Quoted text here. Click to load it

Not a good idea since a switch is "bouncy" (i.e. mechanical bounce). Look up
switch de-bounce, or switch mechanical bounce, as a topic.

The point is that the switch does not have a clean open-close transition. It
"chatters" open/close many, many times, over long periods (can be 10's of
ms). So, if you put a toggle flop between the switch and the pio pin you
will simply do a divide-by-2 of the total number of transitions and the
state of the flop will be random when compared to the state of the switch
(the number of bounces is not predictable).

TC



Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(
Quoted text here. Click to load it
up
It

A Small "key" controller maybe!
There are some "real" interrupts available as well,
and they should be configurable as edge or level triggered.
The Pin change interrupt are not.

Quoted text here. Click to load it




Re: AT91RM9200: PIO: im getting two interrupts when i press the switch once :-(
Quoted text here. Click to load it

Virtually all debouncing schemes depend on timing, and thus can be
beaten.  The one really immune circuit is the break before make
SPDT switch, used to set/reset a flip-flop.  You can build the flop
out of two nand gates, or even by polling two i/o pins.  

   REPEAT
      IF bit AND resetsig THEN bit := false
      ELSE IF NOT bit AND setsig THEN bit := true;
      (* Do something else *)
   UNTIL hellfreezesover;

where setsig and resetsig are created from the closure of the two
switch throws.  Because the switch is break before make they cannot
occur simultaneously.

--
Chuck F ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.

Site Timeline