Hello,
I am using CW6.3 for programming Coldfire V1 MCF51em256.
In my code I need to use trignometric functions sin, cos, asin and acos. Below is the simple code that I tried.
fPhaseAngle[ucPhase] = acosf(g_stBasicCal.m_afPowerFactor[ucPhase]);
fInPhase += g_stBasicCal.m_afRMSCurrent[ucPhase] * cosf(fPhaseAngle[ucPhase]);
fQuadrature += g_stBasicCal.m_afRMSCurrent[ucPhase] * sinf(acosf(g_stBasicCal.m_afPowerFactor[ucPhase]));
fNeutral = ((fInPhase * fInPhase) + (fQuadrature * fQuadrature));
fNeutral = sqrtf(fNeutral);
However I am getting link errors while using them.
1st time when I used these functions I got the following error:
Link Error : Overflow in segment: code from section: .text
Segment reserved size is: 0x0001ffec -- Overflow of: 0x00001aa8
Link failed.
This made me think that maybe my code is overflowing, however when i checked my code size, there was still lotta free space. Therefore, I started changing the "Standard settings" by trial and error; and selected the "position independant code and data" option for coldfire processor from the code generation tab! After that i stopped getting the above error, however, got a new one!!!
Link Error : unable to find EWL lib:
v1\pi\libm.a
Now I am completely confused... and I would really appreciate if someone could explain to me why I am getting the above errors or how to use trignometric functions correctly and whether I need to do anything else other than including header file <math.h> to do trignometric calculations.
Thank You in advance for even the slightest of help.
It appears that you are attempting to build the program without the proper runtime library that has floating-point support for the trig functions.
For more information on the choice of libraries to use, check out the ColdFire Build Tools reference manual, in particular the chapter, ColdFire Runtime Libraries.
---Tom