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.
Can't compile/download square root function
Moderator: Benj
Can't compile/download square root function
- Attachments
-
- sqrt_fail.fcf_arm
- (5 KiB) Downloaded 237 times
Jeppe
Don't say oups!? Say Interesting!
Don't say oups!? Say Interesting!
Re: Can't compile/download square root function
I also can't compile the MOD (modulo) function.
Jeppe
Don't say oups!? Say Interesting!
Don't say oups!? Say Interesting!
- 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
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
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
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: Can't compile/download square root function
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:
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:
And as I said, it works in simulation.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
Jeppe
Don't say oups!? Say Interesting!
Don't say oups!? Say Interesting!
- 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
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:
(Note I'm only assuming this function exists in v4, I'm using v5 to test this, so sorry if it doesn't!)
Jonny
Code: Select all
result = flt_rem(dividend, divisor)
Jonny
Re: Can't compile/download square root function
I just found that there is a separate FLOAT function for using modulo with Float numbers.
Problem solved.fmod( x , y ) - floating point modulus (remainder of x divided by y)
Jeppe
Don't say oups!? Say Interesting!
Don't say oups!? Say Interesting!