cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Floating Point in Keil

osama
Associate II
Posted on January 22, 2013 at 08:32

Hi,

I am using STM32f4discovery board and am trying to write a code which will take moving average of accelerometer data. For this purpose my average variable have to be in floating point. But during initialization when my code reaches to the following statement

avgx = 0.0;

the processor ends up in hard fault handler. Now as Discovery board supports floating point processing I am assuming that I have missed enabling it in Keil. So i have added '--fpu' to assembler flags but now during linking I get this error

startup_stm32f4xx.s: error: A3903U: Argument '-I' not permitted for option 'fpu'.

Can anyone help me to how to enable it i.e which assembler directives do I have to do this

Regards

#stm32f4-discovery-fpu
3 REPLIES 3
Posted on January 22, 2013 at 09:32

Project Options -> Target -> Floating Point Hardware -> Use FPU

You must then have code to enable the FPU hardware prior to using any FPU instructions. This is typically in the ResetHandler or SystemInit() system_stm32f4xx.c

void SystemInit(void)
{
/* FPU settings ------------------------------------------------------------*/
#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2)); /* set CP10 and CP11 Full Access */
#endif
...

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

Thanks clive1 that worked perfectly

shafqathussnain
Associate II
Posted on May 10, 2014 at 18:36

Sir,

I am using STM32F4 Discovery I am having problem with it when ever I connect it with USB through PC it does not show SWD and JTAG and its LD1 remains green and its IC for debugging becomes very hot. Even if I connect it with external supply this IC STM32F103C8T6 becomes very hot.

Before this it was working properly. Last time when it started this behavior I was debugging my code.