How to use sin function on CW6.3

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

How to use sin function on CW6.3

5,152 Views
Kremer
Contributor I
Hi
 
 Sounds like a very very newbie thing but i can´t use the sin function wich was supposed to be Ansi C on math functions.
 I included the math.h on the top of my main source but still getting Link Error: Undefined "sin" message when trying to compile it.
 Please, any help is appreciated.
 
 Thank you
 
Labels (1)
0 Kudos
10 Replies

835 Views
Lundin
Senior Contributor IV
That error might appear if you didn't pick float numbers when creating the project. This will probably be very platform-specific, but at least for the 8-bit and 16-bit mcu:s you need to specify that you wish to use float numbers, or the compiler will pick an integer version of the ansi**.lib. The last letter of the ** (might be 1 or 2 letters) is telling 'f' or 'i' for float or integer.

If you accidently picked the wrong version when creating the project, then SAVE a copy of the project, remove the NO_FLOAT compiler option, remove the faulty ansi.lib from the project and replace with the correct one.

Or if you are unsure about the above, make a new project.
0 Kudos

835 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
What is the Tool version used ?

To do that you must:
* CW:
Start the IDE and click on Help | About Metrowerks CodeWarrior.
Click on Installed Products
Provide us all info displayed.

Pascal

0 Kudos

835 Views
Kremer
Contributor I
Hi mate
 
 Thank you for your reply. I didn´t put the version on my previous post because it was on the title, but i´m using Code Warrior V6.3 and i have a M52233DEMO board.
 I´m trying to implement some FIR filters and i need the sin and cos standard math functions to calculate de impulse response for a given cut off frequency.
 Attached is the information requested about the installed products on CW6.3 i have installed.
 I´m still no able to use sin and cos functions. Any help is useful.
 
 Thank you again
 Regards
 
0 Kudos

835 Views
trytohelp
NXP Employee
NXP Employee
Hi,
 
See below the feedback I received from the Coldfire support team.
If this will not help you, please log the problem in the Freescale Support  Data base via the web:
Click on Submit A Service Request.

Sometime ago I had a similar issue about sin() function.

- customer must use C_TRK_4i_CF_FPU_MSL.a instead C_TRK_4i_CF_MSL.a (must use MSL with floating point unit FPU)

- must use A6 frame and rebuild MSL library

I attached here my old comments:

Please use attached CF_M5485EVB_C.mcp from 5485math.zip.

Target "M5485 Console Debug" uses "C_TRK_41_CF_FPU_MSL.a" library Target "M5485 ROM" uses "C_41_CF_FPU_MSL.a" library

For "M5485 Console Debug" target you must recompile "C_TRK_41_CF_FPU_MSL.a" library using a6 frames ON.

- Open "...\E68K_Support\msl\MSL_C\MSL_E68k\Project\MSL_C.CF.FPU.mcp (see MSL_C.CF.FPU.mcp.jpg)

- Select TRK 4i FPU ColdFire target (see MSL_C.CF.FPU.mcp_target.jpg)

- a6 frames ON (see A6frame.JPG)

- Build (F7) (in my test I must not include "math_fpu_cf.c" file (see math_fpu_cf.c.jpg).

- Check if C_TRK_4i_CF_FPU_MSL.a has a new date (see C_TRK_4i_CF_FPU_MSL.a.jpg).

Rebuild CF_M5485EVB_C.mcp project. I tested sin function and now it is working fine.

Please use the same for "M5485 ROM" target.

Pascal

 

misc.zip

Message Edited by t.dowe on 2009-10-29 09:18 AM
0 Kudos

835 Views
Kremer
Contributor I
 Hi Pascal
 
 Thank you for your reply. I was reading about this modification on the compiler regarding to library sets and the M52233DEMO_C.mcp sample project was using the reduced working set of them (SZ on their name). So i tried to change the files from C_4i_CF_SZ_MSL.a and C_TRK_4i_CF_SZ_MSL.a to their respective complete floating point file (without the SZ and with FPU instead).
 As a result, i still couldn´t build the project because the linker generates 3 errors:
 
" Link Error     : Overflow in segment: user from section:  .text
 Segment reserved size is: 0x00007b00 -- Overflow of: 0x00000c10
 
 Link Error     : Overflow in segment: user from section:  .data
 Segment reserved size is: 0x00007b00 -- Overflow of: 0x000010b0
 
  Link Error     : Overflow in segment: user from section:  .bss
 Segment reserved size is: 0x00007b00 -- Overflow of: 0x000014c8"
 
Then i read your reply and executed the steps you mentioned. I´m still getting the same errors.
Remember i´m using MCF52233 and not MCF548x mcu. So, as a third try, i modified the Target CPU on ColdFire Processor window of the MSL_C.CF.FPU.mcp (target TRK 4i ColdFire FPU) to my case (MCF5223x) but when i tried to build the MSL_C.CF.FPU.mcp again i got about 944 errors. I just quit it...
 So i succefully compiled the M52233DEMO_C.mcp when i switched back to C_TRK_4i_CF_SZ_MSL.a, but still using the new C_4i_CF_FPU_MSL.a. As a result, when i tried to debug it, the code generated by the compiler has invalid opcodes causing the system to crash.
 So i´m still unable to use sin and cos math functions. I´ll try the support.
 If anyone knows how to solve it on MCF52233 mcu please, any sugestions are welcome.
 
 Thank you
Regards
 
0 Kudos

835 Views
trytohelp
NXP Employee
NXP Employee
Hi Kremer,
 
Sorry but I can not help you.
This issue must be handle by a support engineer.
You must log this issue in the Freescale CRM system.
 
Regards
Pascal
0 Kudos

835 Views
Kremer
Contributor I
Pascal
 
 Thank you for your help. Just as the freescale support informed me, those math functions can´t be added to targets different from internal ROM. Since i was trying to build the project for Console Debug and Uart Debug Target, the linker was generating those errors.
 So, removing the TRK file from the project and building it to Internal Rom Target abled the math functions to work right.
 One important point to be noticed is that sinf and cosf functions are "buggy" functions and should not be used by the programmer unitl the next code warrior release.
 
 Best regards
 Kremer
0 Kudos

834 Views
J2MEJediMaster
Specialist I
If the results from those functions are in error, you need to submit a service request (SR) so that something gets done about it. I think the means for posting an SR have been covered in this thread earlier. However, I'll repeat it here:

To log the issue, go to following URL:
http://www.freescale.com/TechSupport
and follow the "Submit a service request" link.

Make sure to attach the whole project reproducing this behavior. You can use CodeWarrior's pack and go wizard that can be started from Help -> Pack And Go to collect all the necessary information.

---Tom
0 Kudos

835 Views
Kremer
Contributor I
 Hi Tom
 
 Thank you for your inform. I already had a service request opened for this little problem i was having with math functions and Alfredo was helping me. He told he was abled to see the error on sinf and cosf functions and he answered me ha was forwarding this issue to developers. So, i think the procedure for this bug fix was already initialized.
 
 See the message below:
 
"Are you working with radians? I´m able to see the issue but in this case I need report to the developer, it will take time to fix the libraries, you need create your own cosf function for the moment, until the bug appears fixed in the next release. I apologize for this inconvenience.

Should you need to contact us with regard to this message, please see the notes below."
 
 Thank you.
 Regards
 Kremer
0 Kudos

835 Views
Nouchi
Senior Contributor II
Hi,

This thread could be a piece of your answer:
http://forums.freescale.com/freescale/board/message?board.id=CWCOMM&message.id=2183
and this document too:
"C:\Program Files\Freescale\CodeWarrior for ColdFire V6.3\Help\PDF\ColdFire_Build_Tools_Reference.pdf"

Emmanuel

Message Edited by BugMan on 2007-02-1408:23 AM

0 Kudos