Page 1 of 1

Type Casting

Posted: Fri Nov 13, 2009 7:02 am
by luthra_arun
Hi to all,
I am getting the problem with splitting the float variable into two Bytes in the Flowcode simulation it is working but on the actual h/w the value of higher byte and lower byte are 0 and 0 respectively.I had check all the parameters like clock freq,MCU configuration.The other program are running on the same h/w
even splitting the integer in to byte is also working .Splitting the float into byte is not working.

Re: Type Casting

Posted: Fri Nov 13, 2009 7:08 am
by luthra_arun
For the Above post i am sending you the File which i had make.
Type Casting.fcf
(7.5 KiB) Downloaded 354 times

Re: Type Casting

Posted: Fri Nov 13, 2009 9:09 am
by Benj
Hello Luthra

Your program should compile and run correctly on the hardware if you use the HITECH compiler (Flowcode v4.2) which can nativly support floating point variables.

If you want to keep using BoostC then you will have to use the floating poing functions located in the functions window of the calculation icon properties.

Eg instead of

Float_Test = Float_Test * 10

You would need

Float_Test = fmul(Float_Test, 10)

Likewise to convert between floating point and other variables with BoostC you will need to use something like this.

Flowcode_Int_Var = float2int(Float_Test)