Hi,
i'm using ICUDriver on STM32f4 but i have a problem when i try to read the return value from "icuGetWidth(icup)" function.
In particular, i can't cast this value to int or float.
STM32 - Cast from icucnt_t to float
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32 - Cast from icucnt_t to float
Hi Giovanni,
Distance is always 0 and say me the warning "optimized out".
Thank's for the reply
Code: Select all
static void icuwidthcb(ICUDriver *icup) {
palSetPad(GPIOD, GPIOD_LED4);
last_width =icuGetWidth(icup);
}
icucnt_t last_width;
static void SRF05init(){
uint16_t distance = 0;
distance= last_width/58;
}Distance is always 0 and say me the warning "optimized out".
Thank's for the reply
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: STM32 - Cast from icucnt_t to float
Is the callback actually called? try putting a breakpoint there.
Giovanni
Giovanni
Re: STM32 - Cast from icucnt_t to float
Yes it is, infact if i put the mouse on "last_width" in debug mode, i can see the right value
thank you
thank you
Re: STM32 - Cast from icucnt_t to float
Stupid question, but is the value of last_width you're seeing larger than 57? If it's not then integer divide is just going to return 0;
Secondly, declare the variable with volatile if you don't want the optimizer to touch it:
Secondly, declare the variable with volatile if you don't want the optimizer to touch it:
Code: Select all
volatile icucnt_t last_width;