EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

gcc compiler and byte / word alignment

Started by Fred October 17, 2005
On 2005-10-18, Fred <fred@nowhere.com> wrote:

>> A word is 32 bits in the ARM world and must be word-aligned. A half-word >> is 16 bits and must be half-word aligned. The LPC2294 is an ARM7tdmi >> MCU and thus doesn't support unaligned accesses in hardware. >> > The half-word is half-word aligned albeit on an 8 bit bus.
I haven't used the LPC2994, but in general that's OK on the other parts with which I'm familiar.
> Temporarily I have used byte access and concatenated the > bytes. However this really isn't an ideal and is a slow > solution. I've been looking through the datasheets and can't > see any proviso that a half-word read won't access a variable > on an 8 bit bus.
Try it and see. :) -- Grant Edwards grante Yow! Life is selling at REVOLUTIONARY HAIR visi.com PRODUCTS!
"Grant Edwards" <grante@visi.com> wrote in message 
news:11la1a7jqkh3ib4@corp.supernews.com...
> On 2005-10-18, Fred <fred@nowhere.com> wrote: > >>> A word is 32 bits in the ARM world and must be word-aligned. A half-word >>> is 16 bits and must be half-word aligned. The LPC2294 is an ARM7tdmi >>> MCU and thus doesn't support unaligned accesses in hardware. >>> >> The half-word is half-word aligned albeit on an 8 bit bus. > > I haven't used the LPC2994, but in general that's OK on the > other parts with which I'm familiar. >
I agree therefore my surprise. I've looked with a 'scope and it seems as if there's a single read. The bigher byte of the half word mirrors the lower byte.
>> Temporarily I have used byte access and concatenated the >> bytes. However this really isn't an ideal and is a slow >> solution. I've been looking through the datasheets and can't >> see any proviso that a half-word read won't access a variable >> on an 8 bit bus. >
On 2005-10-18, Fred <fred@nowhere.com> wrote:

>>> The half-word is half-word aligned albeit on an 8 bit bus. >> >> I haven't used the LPC2994, but in general that's OK on the >> other parts with which I'm familiar. > > I agree therefore my surprise. > > I've looked with a 'scope and it seems as if there's a single > read. The higher byte of the half word mirrors the lower > byte.
Bummer. IMO, what you have isn't really an 8-bit bus. It's half of a 16-bit bus or a quarter of a 32-bit bus. I can just hear the marketing guys saying "Can't use 16-bit operations on the peripherals? That's OK, will just add '8-bit bus support' to the list of features". -- Grant Edwards grante Yow! I will SHAVE and at buy JELL-O and bring my visi.com MARRIAGE MANUAL!!

The 2024 Embedded Online Conference