Simple example for floating point on the MCF52234 (CW 7.2)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Simple example for floating point on the MCF52234 (CW 7.2)

961 Views
smith_jones
Contributor I

Hello

 

I am in the bring-up phase of our new design with the MCF52234 using the CodeWarrior 7.2. I need the pow(), log() and exp() functions for some calculations.

 

Does anyone has an example how and what to include to be able to use this functions?

 

Thanks in advance.

Labels (1)
0 Kudos
3 Replies

354 Views
vier_kuifjes
Senior Contributor I

This has never been clear to me either, but I have figured a way around this.

At a certain point I needed to use some math functions in my program and faced the same problem as you have now.

 

In CW7.1, the source code of the libraries was present, including the code of the math functions (not sure if this is also available in CW7.2 as this uses a different approach). What I did was to extract the source code of the functions that I needed from the libraries and merged the code with my code.

 

This has 2 advantages ;

- only needs float.h

- no need to include a large library of math functions in your program

 

Disadvantage : the functions I use are only single precision.

 

I have included the source code I use in attachment. All functions you need are in there + some others. They work fine with CW7.2 also!

0 Kudos

354 Views
smith_jones
Contributor I

Hi Marc

 

Thanks for your response. I will try to use your enclosed code but I tried a little more and I think it works very well just to add the line: #include <math.h>. The code below:

 

c = exp(0.5);     

  c = pow(2,2);     

  c = log(2);

 

gives the results 1,64872..., 4 and 0,69... which seems to be quite correct. The new library format (EWL) in CW7.2 seems to pick just what you need. The downloaded code increase with about 10kB for exp(), 9kB for pow() and about 3kB for log() functions. I will test your code and I hope it will add even less code.

 

Regards

2B

0 Kudos

354 Views
vier_kuifjes
Senior Contributor I

That's good to hear. I never really gave it a try with CW7.2. I'm still using CW7.1 as my project is Coldfire Lite based, which has issues with CW7.2. But with CW7.1 I could never get it to work...

0 Kudos