Page 1 of 1

float2int

Posted: Sun Mar 06, 2011 2:10 am
by billduck
I have a question about a compile error. In a large program, I am passing a couple of floats to a macro. In the macro, I define an integer data type, and convert the float to an integer. When I compile, I get the error " undefined reference to `float32_to_int32' ". I wrote a short program, main and 1 macro, and it will simulate, but has the same error message. Any suggestions?
Thanks in advance.

Re: float2int

Posted: Sun Mar 06, 2011 8:02 pm
by Sean
I will look into the function naming problem.

As a workaround. It is possible that the two functions to convert, in either direction, between floats and ints are not required in Flowcode for AVR. Their main purpose is to allow import/export compatibility with Flowcode for PIC. The compiler seems to be capable of automatically converting between the basic numeric data types - if the values are valid:

float_var = int_var
int_var = float_var

If you want to use the float_to_int function, putting the following line in the supplementary code section of the program (view -> Project Options -> Supplementary Code) prevents the compiler error:

#define float32_to_int32 float32_to_int

Re: float2int

Posted: Sun Mar 06, 2011 9:49 pm
by billduck
Thanks, That worked for compiling.
I added another operation - square root of the sum of the squares, and the error is, when compiling, " undefined reference to `float32_sqrt' ". Is there is similar fix to make that compile?
I uploaded the modified Flowcode example.

Re: float2int

Posted: Mon Mar 07, 2011 11:48 am
by Sean
Hello,

I have attached a new 'internals.h' file that should correct the name problems identified with 3 floating point function calls:

float to int
int to float
sqrt
internals.h
(2.16 KiB) Downloaded 647 times
The file should be copied into the FCD folder of the Flowcode AVR V4 installation (overwriting the original).

Re: float2int

Posted: Mon Mar 07, 2011 2:45 pm
by billduck
Thanks So much. My project could not move forward without your help.

Re: float2int

Posted: Fri Jul 29, 2011 12:09 pm
by petesmart
Hi Sean,

I have had similar issues on FC PIC V4.3... is there a fix for this available?

best regrds

Pete

Re: float2int

Posted: Mon Aug 01, 2011 4:08 pm
by Benj
Hi Pete,

Are you having the problem with PIC or dsPIC? If its with PIC then have you tried upgrading to v4.5 and seeing if the problems still exists?

Re: float2int

Posted: Mon Aug 01, 2011 9:38 pm
by petesmart
Hi Ben,

Its on PIC version... I will give v4.5 a go and come back to you...

Thanks

Pete

Re: Int2float

Posted: Mon Oct 31, 2011 2:07 pm
by petesmart
Hi Ben,

Attempting to convert an integer to floating point number and get the following error on both ARM and dsPic versions... software I belive is the latest version Flowcode PIC24&dsPIC v4.4.13.69. Have not had a chance to verify on FC PIC v4.5

Created a small test file to demo the problem

Comes up with these errors on compile

int 2 float test 1.c: In function 'main':

int 2 float test 1.c:81: warning: implicit declaration of function 'float32_from_int32'


then this one on assemby

int 2 float test 1.o(.text+0x618):O:\matrixmultimedia\test files\inclinometer\inclinometer v2\int 2 float test 1.c: undefined reference to `float32_from_int32'

Error returned from [pic30-gcc.exe]

Return code = 1

Flowcode was unable to assemble the ASM file due to the following errors
:

test Files attached

I am suspecting a library problem.....Appreciate your help..


Thanks

Pete

Re: float2int

Posted: Mon Oct 31, 2011 6:01 pm
by Benj
Hello Pete,

You could add this line of code to the supplementary code window to resolve the problem.

Code: Select all

#define float32_from_int32(a)   ((float)(a))
Let me know how you get on.

Re: float2int

Posted: Tue Nov 01, 2011 6:17 am
by petesmart
Hi Ben,

Ok, that little piece of black magic worked on both ARM and dsPic ver of FC :D ...and I just realised i'm probably in the wrong forum space...my apologies.

Can you assist with some further

0) is this a bug, or something that I should have known? ( I am still remembering what I've forgotten in this space) :lol:

1) Can you explain why the definition is required in both Arm and dsPIC, FC PIC seemed to be ok?

2) I take it that the (a) is the variable to be processed by the function.. do i have to do this for every variable that I use with this function?

3) and... what about the other functions, such as float2int?

thanks again for the prompt response.. much apprecaited

best regards

Pete

Re: float2int

Posted: Tue Nov 01, 2011 10:53 am
by Benj
Hello Pete,

0) This is a bug and is due to the fact we got the name of one or two of the float conversion functions a bit wrong. This has now been fixed for future revisions.

1) FC PIC has the float functions built into the compiler. AVR, ARM and dsPIC do not have the functions and do not need to use them however we have added them in for full compatibility with PIC programs so imports etc work correctly.

2) 'a' is a substitution for the definition's parameter and is merely a pre-processor symbol. i.e. you do not need to redefine using other letters.

3) I think most of the functions are fine however If you find another that will not compile then let me know.

Re: float2int

Posted: Tue Nov 01, 2011 11:33 am
by petesmart
Thanks Ben,

0) when you were referring to future revisions, am I up to date with both ARM and dsPIC? I did check via the FC application for updates and it did respond with no updates available?

1) am I correct in undersatnding that ARM and dsPIC you can simply make float equal integer or integer equal float without using the int2float or float2int function?

Thanks again for your prompt follow-up,

all the best,

Pete

Re: float2int

Posted: Tue Nov 01, 2011 1:34 pm
by Benj
Hello Pete,

0) Yes if the Flowcode portal page is saying you are up to date then there is currently no updates available for that version of Flowcode. I always ensure to keep the portal page up to date as updates are released.

1) Yes thats right, the functions are not required for ARM, AVR or dsPIC. In fact they are only required by the BoostC compiler. The HiTech compiler for PICs can also be used without the functions.