Re: [bascom] INT0 causes RESET ?
Hi Jon,
Actually, the safest thing to do while servicing an interrupt, is to turn
off all interrupts then service the particular interrupt, and then reset the
interrupt function.
Most all of the programmers that I meet and advise all seem to make the same
mistakes in writing their programs. And that is 'Error Checking' and 'Error
Prevention'. In your case you have a problem with 'Error Prevention' in that
although your function operates correctly, if the same or similar conditions
prevail, your function starts having problems. So for a Interrupt Function
one would stop all, or at least stop all lower level, interrupts from
triggering the interrupt system while the Interrupt Function is in effect.
So for your application I would halt the Interrupt system, process the
interrupt, and then turn the interrupt system back on.
As for debouncing, the best method is to debounce the signal before the CPU
sees it. Granted, the BASCOM DEBOUNCE function is nice, but nothing can
substitute for correctly designed hardware. (Plus debounce circuits are drop
dead easy to design and are cheep (as opposed to spending hours and hours
debugging a program that is responding to a noisy signal)).
Good Luck!
--
Michael W. Akers
M. Akers Enterprises
BASCOM US Sales and Support
http://www.mwakers.com
----
The surest sign that intelligent life exists elsewhere in the universe
is that it has never tried to contact us.
----- Original Message -----
From: "John Johnson" <jj5412@earthlink.net>
To: <bascom@grote.net>
Sent: Saturday, December 16, 2000 2:29 PM
Subject: Re: [bascom] INT0 causes RESET ?
> ----- Original Message -----
> From: "Michael Wieser" <m.k.w@nextra.at>
> To: <bascom@grote.net>
> Sent: Saturday, December 16, 2000 12:46 PM
> Subject: Re: [bascom] INT0 causes RESET ?
>
>
> > >Apparently this got lost the first time I sent it. Apologies if it's a
> dupe.
> >
> > Apologied, (at least from my point of view)
> > but no apologies for no info which bascom (avr, 51) or compilerrelease
nor
> > info about the CPU, Spped of the CPU and other stuff..... (discussed
only
> > some days ago here on the list !! )
>
> True. I forgot this is a BASCOM list, and not a BASCOM-AVR list. So:
>
> AT90S2313-10PI (i.e. AVR) clocked at 4 MHz
>
> BASCOM-AVR IDE Version : 1.11.0.0
> Compiler: Version 1.11a
> Serial : Serial DEMO
>
> > anyway, it seems that your push button does bounce(?) and the cpu is
very
> > fast, so it "sees" this bouncing as 2 independent keystrokes, try to
> > debounce the keys.
>
> Sounds feasible, except:
> I'm not using the DEBOUNCE instruction.
> When in the interrupt service routine (ISR) there are two possible
> scenarios. If another interrupt is ignored while in the ISR, it would not
> cause the problem. Another possibility is an interrupt causing another
jump
> to the ISR while already in the ISR. This could in theory blow the stack
if
> too many interrupts occured. I don't believe this to be the case since the
> problem occurs with an IR sensor connected to the pin (which doesn't
> bounce). Should I explicity turn off interrupts (or this interrupt) at the
> start of the ISR, then re-enable at the end? Think I'll try that.
>
> Thanks for the reply and the reminder.
>
> Regards,
> JJ
>
>
>