This technical note describes actions to take when an unaligned access leads to a ‘Usage Fault’ or ‘Hard Fault’ exception.
This technical note applies to devices based on the ARMv7-M or ARMv8-M architecture.
(For other architectures, see below.)
There are two different suggestions for avoiding exceptions:
The first suggestion makes the device accept unaligned accesses. When the device is set up in this manner, the IAR C/C++ Compiler™ can generate more efficient code. The runtime library is built to take advantage of this.
The second suggestion is for when the 'UNALIGN_TRP' bit is set by the application. In this situation the linker will redirect affected library functions to function variants that handle the unaligned accesses. These variants are less efficient.
The devices based on the ARMv7-M or ARMv8-M architecture can take advantage of this technical note:
More information can be found in your hardware documentation, for example, ‘4.3.9. System Handler Control and State Register’ in ‘Cortex-M3 Devices Generic User Guide’ and in ‘4.3.6. Configuration and Control Register’ in ‘Cortex-M0 Devices Generic User Guide’.
All product names are trademarks or registered trademarks of their respective owners.