cancel
Showing results for 
Search instead for 
Did you mean: 

u32 should be alligned ?

wadi
Associate II
Posted on February 11, 2012 at 01:17

hello

One question:

when i am using:

char table[10];

(...)

*(unsigned int*)&table[1]=0x12345678;

should the pointer be dword alligned in RAMy ? Can I make safely such access?

Or it is forbidden in ARM architecture

thanks in advance

1 REPLY 1
Posted on February 11, 2012 at 01:52

The Cortex-M3 supports unaligned writes, the ARM 7 and 9 do not. Writing such code is non-portable and inefficient, and therefore probably best avoided.

On ARM 7 and 9, you'd typically use a memcpy() construct, and if the compiler were smart enough it would in-line appropriate code for short copies and the target architecture.

http://www.arm.com/files/pdf/IntroToCortex-M3.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..