Skip to main content
Graduate II
May 15, 2024
Question

Hard Fault with Floating point and DSP

  • May 15, 2024
  • 2 replies
  • 1574 views

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):

luke514_1-1715783123103.png

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.

    This topic has been closed for replies.

    2 replies

    Graduate II
    May 15, 2024

    >>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?

    luke514Author
    Graduate II
    May 15, 2024

    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

    Graduate II
    May 15, 2024

    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

    Technical Moderator
    May 15, 2024

    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

    luke514Author
    Graduate II
    May 16, 2024

    The error appears the same with all types of optimizations, I just tried.