[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] efficient Timer Interrupts
From: |
Keith Gudger |
Subject: |
Re: [avr-gcc-list] efficient Timer Interrupts |
Date: |
Wed, 22 Oct 2003 09:15:25 -0700 (PDT) |
First, why do you need to save the 2 to 4 cycles that using RAM (vs
registers) saves? If your interrupt routine is taking too long, just set
a flag in your interrupt routine and do your external A/D processing in
your main loop. This will save a whole lot more than just putting the
variables in registers.
If you still want to save these 2 cycles, look for some I/O location
you're not using, and use that to store your variable. INs and OUTs take
only 1 cycle (like using registers).
On Wed, 22 Oct 2003, Torsten Hahn wrote:
> Hi,
>
> i have an application where i want do stuff in an timer interrupt, but
> i want do the stuff only n times. So a solution would be the following:
>
>
> volatile uint16_t cnt = 10000;
>
>
> SIGNAL(SIG_OUTPUT_COMPARE0)
> {
> // do stuff, e.g.
> // read data from an extern adc
> // accumulate data ...
>
> if(cnt--) {
> // stop the timer0 / interrupt and set an "ready" flag
> }
> }
>
> The problem for me is, that using an extern (ram) var as a counter
> consumes much processor cycles (loading the var from ram, decrementing,
> write back). Is there a better (faster) solution ? Iam looking for a
> way to stop for example the timer 0 exactly after a given number of
> executions.
>
> Any Ideas ?
>
> thx,
> Torsten.
>
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
>