Hi,
When you say "it's not possible to get the correct result from
the uiBytesBeSector" is this something you've seen in practice, or
just an assumption you're making?
The language definition allows compilers to place fields within
structures wherever they want. Typically, padding fields are added
to ensure the allignment rules of the target processor are met. This
is why it is dangerous to make any assumptions about how fields are
actually stored in memory.
If you're using such a struct to help define the structure of fields
in memory (e.g. in data recived in a particular format on a
communications link), it is non-portable. You can try and use some
form of "packed" type modifier to try and sort this out, but this is
also non-portable. The safest way around this is to read the data a
byte at a time into your structure.
In summary: if you declare the structure shown below, you shold have
no problems, unless you're doing something that makes assumptions
about how the fields are stored (e.g. type-casting a pointer to such
a structure to a pointer to some other type or memory buffer).
Brendan
--- In lpc2000@yahoogroups.com, "struer_trace" <jan@...> wrote:
>
> Hey,
>
> I started messing around with an LPC2148 this week, and until now
> everything has just been great. The CPU is just amazing compared to
> what I have been working with before. I'm porting a project I did
for
> the HCS12 series of CPU's to this ARM.
>
> But one thing is very different from what I'm used to. This LPC2148
> can only access 16bit and 32bits words within even addresses. (As
far
> as I understand from the manual).
>
> And that has become a problem for me when porting my code. Because
I
> have a struct like this:
>
> typedef struct {
> uint8 ucJBC[3]; // Jump to
bootstrap
> code
> uint8 cOEMid[8]; // OEM ID Name of
> the formatting OS
> uint16 uiBytesPrSector;
> uint8 ucSectorsPrCluster; //
> ... etc.
> }
>
> When I compile this it's not possible to get the correct result
from
> the uiBytesBeSector because it's placed on a odd address. So my
> question is... How do I get the correct result from words aligned
odd?
>
> And is it really impossible to make a struct like this? Do I really
> have to make all my structs byte even or make it purely by 16 and
32
> bit words?
>
> I'm using CrossStudio for ARM 1.5 Evaluation and the MAM is set to
mode 2.
>
> Thanks in advance!
>
> Best regards
> Jan Thogersen
>Message
Re: LPC2148 and words on odd addresses.
2006-04-29 by brendanmurphy37
Attachments
- No local attachments were found for this message.