what causes the STM32F429ZI to experience a hard error when attempting to cast a value into float?
Hi guys, what causes the STM32F429ZI to experience a hard error (App_Fault_ISR) when attempting to cast a value into float?
I have come across a problem while using Atollic TrueSTUDIO on an STM32F429ZI Nucleo board. Below is my code:
The crash occurs at this assembly instruction:
The Hard Fault Detected window shows:
Enabling the FPv4-SP-D16 FPU in the Assembler, Compiler, and C Linker settings with Hardware Implementation selected results in triggering a hard fault that leads to App_Fault_ISR.
What might be the cause of this problem?
I have come across a problem while using Atollic TrueSTUDIO on an STM32F429ZI Nucleo board. Below is my code:
The crash occurs at this assembly instruction:
The Hard Fault Detected window shows:
Enabling the FPv4-SP-D16 FPU in the Assembler, Compiler, and C Linker settings with Hardware Implementation selected results in triggering a hard fault that leads to App_Fault_ISR.
What might be the cause of this problem?
Solution
The hard fault occurs because the FPU is not enabled. Add
SCB->CPACR |= (0xF << 20); in your initialization code to enable the FPU, and ensure your project settings in Atollic TrueSTUDIO are configured for FPU usage (-mfpu=fpv4-sp-d16, -mfloat-abi=hard).