beekit and floating point math?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

beekit and floating point math?

2,593 次查看
hdeweyh
Contributor I
    Hello,
I am using beekit 1.6.0 and codewarrior 5.9.0 with the freescale MC13213SRB demo board.
When i export the wireless uart example from Beekit and then import it into codewarrior and try to add floating point arithmetic like this:

unsigned int setValue( float f) {
               f=f+1.0; //add 1 to float
            ...
}

I get a linker error:
L1822: Symbol _FADD_RC ... is undefined
And then the project fails to compile.

Any ideas how to fix this?

Thanks so much,
Heather
标签 (1)
0 项奖励
回复
4 回复数

1,077 次查看
bigmac
Specialist III
Hello Heather,
 
When you first create the Codewarrior project using the wizard, you need to indicate that you require floating point support within the project.  This will ensure that the correct libraries are linked.
 
Keep in mind that the use of floating point will require significant MCU resources, and its use may be governed on the resources required by the Beekit code.  In many cases, it is possible to avoid the requirement of floating point operations, with careful use of integer calculations.
 
Regards,
Mac
 
0 项奖励
回复

1,077 次查看
Mads
Contributor V
Hi,
The Beekit does not utilize the Codewarrior projec wizard, so you can not follow that approach.
 
If you must use the Float format, then you must replace the ansiis.lib with e.g. The anisfs.lib which will include the functions needed for using the "float" and double variable type.
 
The codewarrior help clearly specifies what features the different libs support (seach for ansi library reference)
 
It is common knowledge that using floating point in small CPU's is a very bad idea as it takes up too much code space.
Therefor it is easier to use real numbers and then scale you input if possible.
 
Br,
Mads
0 项奖励
回复

1,077 次查看
hdeweyh
Contributor I
Thank you both for your suggestions. A question: I found a work around for this problem by including the file rtshc08.c in my project as this file conatined the missing defintion. is this a problematic approach?

Thank you again,
Heather
0 项奖励
回复

1,077 次查看
CompilerGuru
NXP Employee
NXP Employee
That works fine, just make sure the rtshc08.c is in the link order before the ansi library,
as the ansi library contains the same file too just compiler with different options.
One difference of this approach to use the floating point ansi library is that this way, sprintf and others wont support "%f"/float/double and that can be a  real space safer in case you use those routines but not with floats. Otherwise using the ansi library may just be a bit simpler.

Daniel

0 项奖励
回复