AnsweredAssumed Answered

Using cortex-m4 FPU with gcc toolchain

Question asked by hooi.soon on May 16, 2012
Latest reply on May 17, 2012 by fm
Dear all, I'm using `Keil uVision` with gcc toolchain (Sourcery Codebench lite for ARM EABI) to program the `STM32F4 cortex M4` chip. 

The compiler control strings I have set are: 
    -march=armv7e-m -mfpu=fpv4-sp-d16  -mfloat-abi=softfp -std=gnu99 -fsingle-precision-constant

When the debugger encounters some mathematical functions (e.g. `asinf()`, `atan2f()` etc), it stops.

I have checked that the arguments for these functions are also of single-precision. 

I think I may incorrectly set the compiler directives for the FPU, but was unable to identify it. 
 
The disassembly code of an example I did:

The debugger can evaluate atan2f(0.3,0.4), but stops at 0x0803B9CA when it evaluates atan2f(a,b). Didn't know why the number works but not the variables.

       377:            float a = 0.3; 
    0x0803B9BA 4B1E      LDR           r3,[pc,#120]  ; @0x0803BA34
    0x0803B9BC 63BB      STR           r3,[r7,#0x38]
       378:              float b = 0.4; 
       379:  
    0x0803B9BE 4B1E      LDR           r3,[pc,#120]  ; @0x0803BA38
    0x0803B9C0 637B      STR           r3,[r7,#0x34]
       380:         float c = atan2f(0.3,0.4); 
    0x0803B9C2 4B1E      LDR           r3,[pc,#120]  ; @0x0803BA3C
    0x0803B9C4 633B      STR           r3,[r7,#0x30]
       381:         float d = atan2f(a,b); 
       382:          
    0x0803B9C6 6BB8      LDR           r0,[r7,#0x38]
    0x0803B9C8 6B79      LDR           r1,[r7,#0x34]
    0x0803B9CA F004F993  BL.W          atan2f (0x0803FCF4)
    0x0803B9CE 62F8      STR           r0,[r7,#0x2C]


Thanks in advance.

Outcomes