This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Memory alignment issues with global buffer

We have a cortex M4F controller, using Keil uVision5 to compile and J-Link base to debug our applications. In our application we have a uint8 type global buffer of some x size, our issue is when we do memset for this global buffer controller is going to hardfault handler, we found the problem is with memory alignment for the global buffer and the problem is fixed by adding __attribute__((aligned)) to the global buffer

 uint8_t global_buf[GLOBAL_BUFF_LEN] __attribute__((aligned));


Can someone suggest any compiler options which would fix this issue without adding something to my code (we don't want to align all the the buffers in use).