avr-gcc-list
[Top][All Lists]
Advanced

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

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


From: Alex Wenger
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Wed, 07 Sep 2005 13:30:42 +0200
User-agent: Mozilla Thunderbird 1.0.6 (Windows/20050716)

Hello,

Vincent Trouilliez schrieb:
> Talking of instruction, I just noticed that there is a MUL instruction
> in my ATmega32 but no DIV instruction ! How is that even possible...
> even age old 8051 has a division instruction... so we can do quick
> multiplications with the AVR, but need 50 times more cycles to do a
> division ?? I hope I am missing something, because I am finding it very
> inconsistent, and extremely disappointing from this otherwise super
> modern and performant MCU...
> In the long term, I was toying with the idea of playing a bit with fuzzy
> logic and 'Z' filters in control applications, but I guess that will
> require intensive maths, so if I can't even do divisions in hardware...
> I better forget it I guess... until Atmel makes a new AVR with a super
> duper MDU built-in...

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




reply via email to

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