cancel
Showing results for 
Search instead for 
Did you mean: 

stm32F4 FPU Question

terter etuet
Associate II
Posted on July 24, 2017 at 17:01

Hello,

i am trying to work with the fpu of the stm32f469-Disco and got some questions...

i am on ac6 systemworkbench/win7/

so far i can compile and run my app that uses float math...

0690X00000607fUQAQ.png

when i look at the disassmbly it looks good: (as far as i can understand this, it uses the fpu-commands vadd.f32, vmul.f32 etc)

0800c842:   beq.n   0x800c8cc <main()+588>

 545              test = 1.0f / (float)(ix%4) + test;

0800c844:   ldrh    r3, [r7, #50]   ; 0x32

0800c846:   uxth    r3, r3

0800c848:   and.w   r3, r3, #3

0800c84c:   vmov    s15, r3

0800c850:   vcvt.f32.s32    s15, s15

0800c854:   vmov.f32        s13, #112       ; 0x70

0800c858:   vdiv.f32        s14, s13, s15

0800c85c:   vldr    s15, [r7, #44]  ; 0x2c

0800c860:   vadd.f32        s15, s14, s15

etc

but:

__FPU_USED is 0 because __VFP_FP__ is not defined (core_cm4.h line 149)

and SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */

doesent get set

SystemInit(void){

  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)

    SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));  /* set CP10 and CP11 Full Access */

  #endif

....

}

shouldent this generate a FPU-FAULT?

and where can i define __VFP_FP__ ?  putting in

0690X00000607evQAA.png

dident help...

many thanks for some enlightment!

3 REPLIES 3
Posted on July 24, 2017 at 17:16

Check for

SCB->CPACR 

code in the Reset_Handler, that's typically where I'd put it.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on July 24, 2017 at 19:01

 ,

 ,

+1

Instead of hunting down an infinite chain of ♯ defines stemming from obscure system headers and some even directly from cc1, I too chose to enable the FPU myself 'manually'.

Sometimes overautomation hurts.

JW

Posted on July 24, 2017 at 20:19

; Reset handler
Reset_Handler PROC
 EXPORT Reset_Handler [WEAK]
 IMPORT SystemInit
 IMPORT __main
 ;FPU settings
 LDR R0, =0xE000ED88 ; Enable CP10,CP11
 LDR R1,[R0]
 ORR R1,R1,#(0xF << 20)
 STR R1,[R0]
 LDR R0, =SystemInit
 BLX R0
 LDR R0, =__main
 BX R0
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

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