rtstofer wrote:
>I have a pointer to an unsigned 32 bit value in an array[512] of
>unsigned chars (actually the partition table of a CF). When I point
>to the value using GCC, it seems that the code is assuming I am
>pointing at the high word and that the low word precedes the high word
>in memory.
>
>I think I am pointing at the low word and the high word should follow.
>
>The byte order within the two 16 bit words is correct.
>
>Any thoughts about what I am doing wrong. I can see the sector dump
>and I can see the results of extracting values and the results are
>wrong. Bytes work and 16 bit words work but 32 bit words do not.
>
>
>
You might have a hardware problem where you are byte swapping? Try
running an IDENTIFY_DRIVE (0xec) command on the CF. This will send you
back a bunch of bytes structured as:
=============== begin ==================
struct DriveID {
Word Signature;
Word NumCylinders;
Word Reserved1;
Word NumHeads;
Word NumUnBytePerTrack;
Word NumUnBytePerSector;
Word NumSectorsPerTrack;
DWord NumberSectorsPerCard;
Word Reserved2;
char SerialNumber[20];
Word BufferType;
Word BufferSize;
Word EccBytesPassed;
char FirmwareRev [8];
char ModelNumber [40];
Word Max1SectorRW;
Word DWnotSupported;
Word Capabilities;
Word Reserved3;
};
=============== end ===================
Try looking at the text string: ModelNumber. That will tell you if byte
swapping is the problem.
I ran into byte swapping issues between the IDE registers and the Data
register while working with a big-endian controller (MC68EZ328).
IIRC, something tells me that the drive data is Big-Endian on the CF and
IDE drives...
TomW
>Richard
>
>
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------Message
Re: [lpc2000] Confused re: endianness
2005-10-18 by Tom Walsh
Attachments
- No local attachments were found for this message.