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

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

Reply to
Mayank Kaushik
Loading thread data ...

On 10 Jan 2005 04:37:28 -0800, "Mayank Kaushik" wrote in comp.arch.embedded:

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
 Click to see the full signature
Reply to
Jack Klein

:-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

Reply to
Mayank Kaushik

or i could put a toggle flip-flop between the switch and the pio pin..hmm, that should work

Reply to
Mayank Kaushik

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

Reply to
TC

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.

"TC" skrev i meddelandet news:x51Fd.4898$ snipped-for-privacy@newsread2.news.atl.earthlink.net...

Reply to
Ulf Samuelsson

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 (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
 Click to see the full signature
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.