[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Global variables and ISRs ???

From: David Brown
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Wed, 7 Sep 2005 16:17:03 +0200

> > For such things it is interessting to use fixed point math.
> > If you want to divide 200 data Bytes by 13 you can do
> >
> > fac = 256 / 13;   (* Only one div needed *)
> > for i := 0 to 199 do
> >    data[i] = data[i] shl 8 * fac;
> >
> > and you need only 1 div and man muls.
> >
> > For data-filters you normaly can avoid doing massiv divs.
> >
> > -Alex Wenger
> Thanks Alex, looks like there is a way to do numerical filtering then,
> great ! :o)  I have one big advantage on my side, too : since I am
> interested in control applications, and the time constant of mechanical
> systems is at the very least 10ms, this gives the AVR (at 16MHz) in the
> order of a million cycles to process each sample, so I guess this allows
> time for plenty of byte crunching and some more ! :o)
> Might even be able to drive two different motors at the same time, and
> still handle a complex user interface, graphics LCD, UART.... wow... I
> love AVR's :o)

I wonder why this sort of optomisation is necessary with avr-gcc.  With
another gcc port I use (for the m68k), gcc will automatically do that sort
of thing.  In particular, it will change "divide by a constant" into
"multiple by a reciprical", and it will also change "multiply by constant"
into a series of shifts and adds.  The target chip has a hardware multiplier
and divider, but they are slower than the shift-and-add sequences.  I was
under the impression that such "strength reduction" was handled by the
front-end of the compiler rather than the back-end, and would thus be in all
gcc ports.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]