float acting like double

Discussions and support about ChibiOS/RT, the free embedded RTOS.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: float acting like double

Post by Giovanni »

Could setVal be corrupted in some unexpected way? a stack overflow or an overflow in some adjacent variable.

Giovanni
jcbless
Posts: 43
Joined: Wed Apr 16, 2025 2:29 pm
Has thanked: 7 times
Been thanked: 3 times

Re: float acting like double

Post by jcbless »

I don't think that a stack overflow is occurring, but I'm not sure that I know exactly what I should be looking for. Please give me some hints. I don't know what to look for regarding an overflow in adjacent variables.

The working area I started with for thread1 was 1024. I've gone as high as 10000 without any change in behavior.

Also another interesting fact is that when it is giving the double like values, it interspaces them with 0's like this:
Float into vSV: 406F4000
Float into vSV: 0
Float into vSV: 406F4000
Float into vSV: 0
Float into vSV: 406F4000
Float into vSV: 0

Thanks,
John
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: float acting like double

Post by Giovanni »

Try to package a very minimal project showing the problem, I am out of ideas.

Giovanni
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: float acting like double

Post by alex31 »

-what fpu option do you use ? (USE_FPU_OPT in Makefile) ?
° for stm32h7, if using FPU, should be -mfpu=fpv5-d16
° If you have several units compiled separately, you must keep -mfloat-abi value consistent in all the project
since it tell the compiler how are passed the float parameters, in fpu registers or cpu registers.

-what compiler ?

After assuring that you have consistent USE_FPU_OPT in all your project, you can try the three possible value : 'no', 'soft', 'hard' to check if you keep the same strange behavior.

To go further, follow Giovanni advice, try a simple example in a single main.c and post it here.

A.
Post Reply