cancel
Showing results for 
Search instead for 
Did you mean: 

Can't calculate a float.

dennisvantienhoven
Associate II
Posted on January 10, 2012 at 11:41

A little question,

When I'm trying to calculate a float I'll get ''ISR   HardFaultVector_IRQn''

What am I doing wrong?

My code:

--------------------------------------------------------------------------------------------------------

uint32_t iTemperature = 0x1b8;

double dTemperature   = 0.0;

dTemperature = (double)iTemperature*0.0625;

--------------------------------------------------------------------------------------------------------

This goes wrong and I don't know why..

MCU = STM32F100RB6TB

Greets,

Dennis
3 REPLIES 3
Posted on January 10, 2012 at 14:04

What am I doing wrong?

 

Using GCC, and importing a 32-bit ARM library for floating point? The Cortex-M3 only runs Thumb (16-bit) code, and Hard Faults with ARM (32-bit) code.

Examine the processor state, identify the instruction that is faulting, should be easy enough to figure out why it dies rather than just guessing. Look at Joseph Yiu's suggested Hard Fault handler, it works better than while(1);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
dennisvantienhoven
Associate II
Posted on January 11, 2012 at 12:07

@clive1

Using GCC, and importing a 32-bit ARM library for floating point?

Which library is this? Where can I find this information?

(yep I'm going to order that book, if that would help me with this kind of problems.)

Greets,

Dennis

Posted on January 11, 2012 at 13:52

libm.o ? I'm not a big GCC guy, but look at the makefile, and look at the -L library pathing. A .map file might also give some insight into the parts brought in by the linker, and a disassembly via objdump.

Joseph comes here occasionally, and there are a couple of examples out the internets.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Hard Fault and stack pushing&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=7790]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FHard%20Fault%20and%20stack%20pushing&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=7790

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..