Skip to main content
Graduate
October 9, 2024
Solved

WRITE_REG hard fault

  • October 9, 2024
  • 4 replies
  • 1273 views

Hallo,

I'm compiling with this option   <-fpack-struct=1>

Why, with this option, the instruction

<WRITE_REG(hdma->Instance->CBR1, 0U);>

generates hard fault? I don't understand, without changing nothing.

thank you.

    This topic has been closed for replies.
    Best answer by TDK

    Either the handle points to an invalid value or you are making an unaligned access. Should be able to debug and investigate one way or the other. Look at the hdma handle and ensure the instance is valid. Look at the hard fault and understand why it occurred. The SCB register will have flags that explain why and where it happened.

    The issue is not with the WRITE_REG macro.

    4 replies

    TDKAnswer
    Super User
    October 9, 2024

    Either the handle points to an invalid value or you are making an unaligned access. Should be able to debug and investigate one way or the other. Look at the hdma handle and ensure the instance is valid. Look at the hard fault and understand why it occurred. The SCB register will have flags that explain why and where it happened.

    The issue is not with the WRITE_REG macro.

    Graduate II
    October 9, 2024

    Hi,

    Is CBR1 a valid DMA register?

    Kind regards
    Pedro

    Super User
    October 9, 2024

    > I don't understand, without changing nothing.

    But you have changed the compiler option, an important one.

    If you've changed anything and things break - undo your changes, re-think and move slower, in smaller steps.

     

    Super User
    October 9, 2024