gnupic: Re: [gnupic] in-circuit debugger
Subject:
Re: [gnupic] in-circuit debugger
From:
Greg Hill ####@####.####
Date:
5 Feb 2007 23:36:56 +0000
Message-Id: <Pine.LNX.4.62.0702051614400.12152@panda.hillnet.us>
On Mon, 5 Feb 2007, Robert Pearce wrote:
> On Mon, 5 Feb 2007 16:31:45 -0500 Byron wrote:
>>
>> There's no need to debounce in hardware. That's why having
>> microcontrollers are useful.
>
> While this is generally sound advice (and when using PICs I like to use
> minimal external components just because) there are cases where you may
> want a simple external debounce. In particular, if your switch feeds
> either a timer input or a pin with interrupts enabled. Usually you
> wouldn't connect a mechanical push-button to either of those, but you
> may be connecting something on a longish bit of potentially noisy wire,
> and a simple RC filter is worth including. But in this case Byron's
> absolutely right.
I might as well chime in on the topic too. :-) I actually make a routine
habit of always connecting mechanical buttons on interrupt lines. I
suppose virtually all battery-operated devices do this; it allows one to
put the processor into low-power sleep mode with no timer or other
provision to ever wake it up. The thing stays asleep until somebody
pushes the button, maximizing battery life.
Software debounce in this scenario requires a little more care but isn't
difficult. Typically the processor will wake and immediately jump to an
ISR, where the interrupt can be disabled so as to prevent a series of
interrupts as the switch bounces. Then, any time it's convenient after
the debounce period (but before going back to sleep, of course!) the
interrupt can be re-enabled.
Greg