Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re: Basic interrupts on ATtiny26

2007-02-19 by Roy E. Burrage

Motorola, now ON Semiconductor, also has/had the MC14490 for switch 
debouncing.  However, at 5 bucks a piece the last time I bought any for 
a control board I haven't taken the trouble to re design, it's much more 
cost effective to write a few lines of code to do the same job in new 
designs.


REB


Adam wrote:

>A couple of years ago I ran into this with an 8051, and my solution
>was to simply wait for 20ms. 
>
>The initial button press would cause the interrupt routine to
>activate. The micro would then wait for 20ms (doing other stuff in the
>meantime of course!), and re-check the interrupt at the end. If the
>interrupt was in the same state, then it was a legitimate button press
>(and not induced noise/etc), and therefore the program should act
>accordingly. Remember as well that when the button is released the
>noise will be present as well, something that bit me on the posterior
>before I took it into account. (Ouch! That took a little while to
>find...."why the !@#$%^&@$^% isn't this $!%^%$@^ working?!?!?".)
>
>You may also wish to consider some IC solutions out there, I think
>(from a hazy memory) that Maxim/Dallas have a keypad decoder chip that
>debounces and decodes the keypress for you, making life a heap easier.
>
>Good luck.
>
>Adam.
>
>--- In AVR-Chat@yahoogroups.com, "Jim Wagner" <jim_d_wagner@...> wrote:
>  
>
>>Manne -
>>
>>There is a big problem that everyone runs into when trying
>>to sense switches with an interrupt. It is called "switch
>>bounce". It happens fairly slowly compared to the speed of
>>the micro. You get MANY interrupts every time the switch
>>opens or closes. 
>>
>>There are several ways to deal with this. One is to "poll"
>>(that is, read) the port pin regularly (maybe once every
>>1ms or so). Make a little "debounce" counter in software
>>and a bit to remember the LAST state read. Every time you
>>make a poll, compare the current state to the last state.
>>If it is the same, count 1. If not the same, put the new
>>state into the last-state bit.  When the debounce counter
>>reaches some convenient value (say 4 or 8), then the switch
>>state is "stable" and you then do what ever else needs to
>>be done (like increment your LED counter.
>>
>>Jim
>>
>>
>>On Sat, 17 Feb 2007 00:37:04 +0100 (CET)
>> "Manne Tallmarken" <mannet@...> wrote:
>>    
>>
>>>Hi all,
>>>I am trying to make my first assembler program that
>>>handles interrupts. On
>>>PB[6:0] I have som leds and on PA[7:6] i have two
>>>buttons. The leds goes
>>>on with a logic one from the port and the buttons is in
>>>tri-state when not
>>>pushed and goes to logic zero when pushed.
>>>I just trying to get a binary counter to show up on the
>>>leds when i am
>>>pushing the buttons but nothing happens.
>>>Does anyone know what could be wrong?
>>>Regards, Manne
>>>
>>>Here is the code:
>>>
>>>.include "tn26def.inc"
>>>


[Non-text portions of this message have been removed]

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.