[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] interrupt optimization
From: |
Nigel Winterbottom |
Subject: |
RE: [avr-gcc-list] interrupt optimization |
Date: |
Wed, 1 Feb 2006 21:36:24 -0000 |
Sent: Wednesday, February 01, 2006 2:32 PM
Sender: David Bourgeois
Subject: [avr-gcc-list] interrupt optimization
> Hi,
>
> I have an interrupt which is called a lot of times but only
> really do
> something very rarely:
>
> ISR(...)
> {
> if (sampling-- == 0)
> {
> sampling = 0x7F;
> callInlineFunction();
> }
> }
> What's the way to go in this situation?
If you can live with a small delay between (sampling==0) & execution of
InlineFunction() then move InlineFunction() to your main loop. Comme ca:
int main (void)
{
for (; ; ;)
{
Function1();
Function2();
if (sampling==0)
{
InlineFunction();
sampling=0x7F;
}
Function3();
_SLEEP(); //Or Whatever
}
}
ISR(...)
{
//Decrement to zero so that the test in the main loop is never missed
if (sampling!=0)
sampling--;
}
This tried * tested method provides a very fast ISR and the ability to
cascade many other timers (e.g. sampling1, sampling2, etc.)
Regards
Nigel Winterbotttom
RE: [avr-gcc-list] interrupt optimization,
Nigel Winterbottom <=
Re: [avr-gcc-list] interrupt optimization, Joerg Wunsch, 2006/02/01
Re: [avr-gcc-list] interrupt optimization, David Brown, 2006/02/02
- RE: [avr-gcc-list] interrupt optimization, MuRaT KaRaDeNiZ, 2006/02/04
- [avr-gcc-list] avr-libc version in Latest WinAVR ?, Anton Erasmus, 2006/02/05
- Re: [avr-gcc-list] avr-libc version in Latest WinAVR ?, Joerg Wunsch, 2006/02/05
- [avr-gcc-list] Memory Size Report, Peter Harrison, 2006/02/05
- Re: [avr-gcc-list] Memory Size Report, Ned Konz, 2006/02/05
- Re: [avr-gcc-list] Memory Size Report, Peter Harrison, 2006/02/05
- Re: [avr-gcc-list] Memory Size Report, Joerg Wunsch, 2006/02/06
- Re: [avr-gcc-list] Memory Size Report, Peter Harrison, 2006/02/05