Can't compile/download square root function

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Odox00
Flowcode v5 User
Posts: 24
Joined: Thu Aug 25, 2011 11:15 am
Contact:

Can't compile/download square root function

Post by Odox00 »

Hi
I put a square root function into a calculation of float point numbers. It works in simulation mode but it fails when I try to compile and download it.
I can read those lines.

sqrt_fail.o: In function `main':
sqrt_fail.c:(.text+0x9f0): undefined reference to `float32_sqrt'


I use Flowcode ARM v.4.3.8.64 and ECRM40.
Attachments
sqrt_fail.fcf_arm
(5 KiB) Downloaded 231 times
Jeppe
Don't say oups!? Say Interesting!

Odox00
Flowcode v5 User
Posts: 24
Joined: Thu Aug 25, 2011 11:15 am
Contact:

Re: Can't compile/download square root function

Post by Odox00 »

I also can't compile the MOD (modulo) function.
Jeppe
Don't say oups!? Say Interesting!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Can't compile/download square root function

Post by Benj »

Hello,

If you click View -> Project Options, then tick Use Supplementary Code, then click the Supplementary code button and paste the following line of code into the top window then the square root function should compile correctly.

#define float32_sqrt sqrt

The MOD function is working ok for me.

test2 = test2 MOD 5

Odox00
Flowcode v5 User
Posts: 24
Joined: Thu Aug 25, 2011 11:15 am
Contact:

Re: Can't compile/download square root function

Post by Odox00 »

Thanks Benj.

Regarding the MOD function. I found out that I can compile if I use INT-variables, but not with FLOAT.

If I try compile <b = (v+360) MOD 360>, (v and b are FLOAT-variables) I get this:
Launching the compiler...
C:\Program Files\Matrix Multimedia\Flowcode ARM V4\Tools\MX_bats\arm7comp.bat "test" "D:\Flowcode"
In file included from test.c:37:
C:/PROGRA~1/MATRIX~1/FLOWCO~2/Tools/MX_bats/../Global/OSstubs.c:192: warning: 'struct tms' declared inside parameter list
C:/PROGRA~1/MATRIX~1/FLOWCO~2/Tools/MX_bats/../Global/OSstubs.c:192: warning: its scope is only this definition or declaration, which is probably not what you want
test.c: In function 'main':
test.c:510: error: invalid operands to binary %
test.c:516: warning: passing argument 3 of 'FCI_FLOAT_TO_STRING' discards qualifiers from pointer target type
test.c:521: warning: passing argument 1 of 'FCD_LCDDisplay0_PrintString' discards qualifiers from pointer target type
test.c:489: warning: return type of 'main' is not 'int'

Error returned from [arm-elf-gcc.exe]

Return code = 1

Flowcode was unable to compile the flowchart's C code due to the following errors:


If your flowchart contains C code, please review this carefully. If your flowchart contains no C-code or you have thoroughly reviewed the code, contact Technical Support.

FINISHED
And as I said, it works in simulation.
Jeppe
Don't say oups!? Say Interesting!

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Can't compile/download square root function

Post by JonnyW »

Hello. Flowcode v4 will let these things through in simulation. However, MOD (%) is illegal in all C compilers for floating point numbers as it only has meaning for integral values, and you must use the functions to convert to integers before performing the mod, or use the flt_rem() function:

Code: Select all

result = flt_rem(dividend, divisor)
(Note I'm only assuming this function exists in v4, I'm using v5 to test this, so sorry if it doesn't!)

Jonny

Odox00
Flowcode v5 User
Posts: 24
Joined: Thu Aug 25, 2011 11:15 am
Contact:

Re: Can't compile/download square root function

Post by Odox00 »

I just found that there is a separate FLOAT function for using modulo with Float numbers.
fmod( x , y ) - floating point modulus (remainder of x divided by y)
Problem solved.
Jeppe
Don't say oups!? Say Interesting!

Post Reply