nRF52832 unaligned memory access

Hi,

Does not nRF52832 support unaligned memory access ?

I had an instruction like this for which the FW was crashing.

Struct A a= *((Struct A*)pSourcePtr);
I replaced the same using a memcpy which will do a byte copy and it does work. 

memcpy(pDstPtr, pSourcePtr, sizeof(Struct A));

Parents
  • Yes and no.

    If sizeof(struct A) == sizeof(int64_t), it may fail depending on which CPU instructions the compiler generated. See the documentation for the LDRD instruction(s) on arm.com website - these instructions require 32-bit alignment while normal LDR/STR do not.

    Other unaligned access is supported by default, but you can disable it with one of the special register bits (forgot the name though).

Reply
  • Yes and no.

    If sizeof(struct A) == sizeof(int64_t), it may fail depending on which CPU instructions the compiler generated. See the documentation for the LDRD instruction(s) on arm.com website - these instructions require 32-bit alignment while normal LDR/STR do not.

    Other unaligned access is supported by default, but you can disable it with one of the special register bits (forgot the name though).

Children
Related