SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By polashd
#156413
MCU= Atmel Avr (Atmega, Attiny..)
Programming software= WinAvr avrgcc

I've downloaded avrfix to use fixed point math in my program.

The zip file contains files named - "avrfix.h" "libavrfix.a" "sizes.txt" (not sure if it is of any use)
Q:-
-How do I use these files for fixed point calculations?
-In which directory these files to be copied so that the IDE (Winavr avrgcc) can use these.
-Do I need to change anything in the make file.

note:-
I created libraries for my self ( pair of files *.c & *.h) for different purposes.
I saved these in the same dir of main.c
By stevech
#156432
interesting. I hadn't seen that fixed point library in the past. Good thing, if it works properly.
Fixed point math is usually MUCH faster and smaller code size on a small/humble microprocessor than floating point in software.

I didn't see any documentation. A quick glance at the .h file showed
Code: Select all
/* Only two datatypes are used from the ISO/IEC standard:
 * short _Accum with s7.8 bit format
 *       _Accum with s15.16 bit format
 * long  _Accum with  s7.24 bit format
 */

typedef signed short _sAccum;
typedef signed long  _Accum;
typedef signed long  _lAccum;
so there are three types: signed with 7 integer bits and 8 fractional bits in a 16 bit short.
The other two are 32 bit longs, one with 16 fractional bit and one with 24 bit fractional part.

The rest of the .h shows macros and calls to the library (.a) routines for math functions.
No source code for the library. Sigh.

Perhaps one can find documentation because of this statement in the .h file
Code: Select all
 * Fixed Point Library                                          *
 * according to                                                 *
 * ISO/IEC DTR 18037  
where this
http://www.open-std.org/jtc1/sc22/wg14/ ... /n1005.pdf

seems to say that the AVR fixed point code in the above is a subset of that in the ISO standard document per the PDF file.
A hero would document this work!