Fixed point math library

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
viki2000
Posts: 190
Joined: Mon Jul 07, 2014 9:38 am
Has thanked: 30 times
Been thanked: 77 times
Contact:

Fixed point math library

Post by viki2000 »

Now Flowcode 7 can use XC16 compiler.

I would like to generate a sine using a fixed point math library as Microchip has in „libq.h” with _Q15sinPI on page 232 next file:
http://ww1.microchip.com/downloads/en/D ... 01456J.pdf
http://ww1.microchip.com/downloads/en// ... 01456j.pdf

The idea is to have the argument of the function and the returned value in the range -32768 to 32767, no (real) floating numbers.
The existing sin() function seems that works with float as argument of the function and the returned value.
http://www.matrixtsl.com/wikiv7/index.p ... _Functions

I realized that I can generate sine also using DSP using a lookup table with integer numbers::
https://www.matrixtsl.com/wikiv7/index. ... ator_(DSP)

but I want to use trigonometric function as sin().

The way how I do it now is implicit, typecasting, by assigning the float variable value to a signed int16 variable.

My questions:
- Is any other more efficient way to do it?
- Is it any other fixed point function/math library as Microchip has „libq.h” with _Q15sinPI ?
- Can we attach somehow the „libq.h” with _Q15sinPI from Microchip?

Post Reply