2024-05-15 07:30 AM - last edited on 2024-05-15 07:34 AM by SofLit
I am using STM32F302R8
I have a long code that triggers the Hard Fault interrupt after a few seconds because of these instructions (of the sine in particular):
The theta_fi angle is TIM6->CNT and I need to convert it from q15 to floating point.
I tried with both arm_q15_to_float function of DSP ... and arm_q15_to_float_new found online.
I can't figure out what the problem is.
2024-05-15 08:06 AM
>>I can't figure out what the problem is.
Perhaps start by looking at what's actually Faulting, what the MCU reports as it's objection, and the registers and code at the site of the fault?
2024-05-15 11:28 AM - edited 2024-05-15 11:28 AM
I can't figure it out because with breakpoints the code works .. while it stops working after a few seconds when debugging without breakpoints so I can't trace back as much informations
I've never had an error like this happen to me so I'm not sure what to do
2024-05-15 12:45 PM
Instrument your code so you know what's happening.
A while(1) loops going to tell you, and support staff on a phone, nothing.
https://github.com/cturvey/RandomNinjaChef/blob/main/KeilHardFault.c
Tend to be gross failures:
Corrupt pointers or stack
Over-run local/auto variable space on the stack
Misaligned pointers
FPU not enabled
Interrupts / register corruption
2024-05-15 02:21 PM
Hi @luke514 ,
try to change the compiler optimization level from best for debug and best for speed or size and see if you observe the behavior change or occurrence of the timings , this will change the generated assembly sequences and code alignment. Let us know .
Ciao
STOne-32
2024-05-16 05:13 AM
The error appears the same with all types of optimizations, I just tried.