Question
stm32f4 random hard faults (solved)
Posted on April 10, 2012 at 23:05
Hi all,
With Keil MDK-ARM I had a random hard fault when I change the optimization level of the compiler. The reason is a VPUSH.64 assembler instruction that tries to use the FPU. This instruction is added by the compiler before entering the main() function, so, at this point, the PFU is not enable. I found a solution at http://e2e.ti.com/support/microcontrollers/stellaris_arm_cortex-m3_microcontroller/f/471/t/155025.aspx?PageIndex=2 Edit startup_stm32f4xx.s file and add the following code in the Reset_handler ; CPACR is located at address 0xE000ED88 LDR.W R0, =0xE000ED88 ; Read CPACR LDR R1, [R0] ; Set bits 20-23 to enable CP10 and CP11 coprocessors ORR R1, R1, ♯(0xF << 20) ; Write back the modified value to the CPACR STR R1, [R0]; wait for store to complete DSB ;reset pipeline now the FPU is enabled ISB Regrds, �ngel #semihosting