When I run this code on my STM32L1 board, the debugger hangs once it reaches to a Float (in this case the variable 'Distance') or Delay, I mean it seems like it's processing, however it never goes through, and I have to close it and run the debugger again, which hangs of course again. Note that the code builds without errors or warnings. Is there's any special configuration for float ?
The following is the related part of the code:
void Delay(int x){ //input milliseconds, delay that number of milliseconds int a,b; for(a=0; a<x; a++){ for(b=0; b<1000; b++){ } } } . . . volatile int timespan = 0; // Total pulse width int main(void){ float Distance; // actual distance in cm . . . while(1){ TIM4_Echo_Read(); Distance = (timespan / 58.0); if (Distance <= 100){ GPIOB->BSRRL = (1<<7); } else { GPIOB->BSRRH = (1<<7); } Delay(10); }
timespan is declared as a global int. Note that none of this happens when I declare Distance as int instead of float.
Any idea why the debugger keeps getting stuck on float instructions?
After it "crashes" press the RED STOP icon and take a screen shot of the code/disassembly window so you can see where it is stuck.
Ok, here's the screenshot:
http://imgur.com/a/xXDSD