Skip to main content
IVent.1
Senior
October 9, 2024
Solved

WRITE_REG hard fault

  • October 9, 2024
  • 4 replies
  • 1302 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

TDK
TDKBest answer
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.

"If you feel a post has answered your question, please click ""Accept as Solution""."
PGump.1
Senior II
October 9, 2024

Hi,

Is CBR1 a valid DMA register?

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
Pavel A.
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.

 

Andrew Neil
Super User
October 9, 2024
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.