ts-7000
[Top] [All Lists]

[ts-7000] pointer weirdness

To:
Subject: [ts-7000] pointer weirdness
From: "Yan Seiner" <>
Date: Wed, 12 Sep 2007 17:23:10 -0000
OK, great gurus of C programming....

I'm stumped, and I know it's something obvious.

I'm in the midst of some code cleanup.  I had a pile of (unsigned int)
addressing 16 bit registers, so I changed everything over to uint16_t.

Here's the basic snippet of code from one of the aflicted registers:

#define QDDR    (0x040c / sizeof(uint16_t))
#define TS733BASE       0x72000000

static uint16_t *qddr;
static uint16_t *ts733gpio;

ts733gpio = (uint16_t *)mmap(0, getpagesize(),
          PROT_READ|PROT_WRITE, MAP_SHARED, fd, TS733BASE);

qddr = (ts733gpio + QDDR);

Now I print qddr:

printf("qddr: 0x%x 0x%x 0x%x 0x%x\n",*qddr,*((uint32_t
*)qddr),*(qddr+1), *((uint32_t *)(qddr+1)));

and I get:

qddr: 0x8cb3 0xff0009b3 0x8c00 0x9b3ff00
qddr: 0x8c6d 0xff000a6d 0x8c00 0xa6dff00
qddr: 0x8c92 0xff000b92 0x8c00 0xb92ff00
qddr: 0x8c3c 0xff000c3c 0x8c00 0xc3cff00
qddr: 0x8c59 0xff000d59 0x8c00 0xd59ff00
qddr: 0x8c4c 0xff000e4c 0x8c00 0xe4cff00
qddr: 0x8c22 0xff000f22 0x8c00 0xf22ff00
qddr: 0x8c7d 0xff000e7d 0x8c00 0xe7dff00
qddr: 0x8c3e 0xff000f3e 0x8c00 0xf3eff00
qddr: 0x8ce9 0xff000fe9 0x8c00 0xfe9ff00
qddr: 0x8c80 0xff001080 0x8c00 0x1080ff00

I get the values I would expect when I cast everything to uint32_t but
uint16_t types *always* start with 0x8c.  What's even more bizarre is
that *all* (uint16_t *) pointers return 0x8c..  The real register
values are the 4 changing hex digits above....

Can anyone shed any light on this?

What is going on?  Can anyone explain this?  My snippet contains *all*
of the code dealing with qddr....

Scratching my head....

--Yan




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/ts-7000/join
    (Yahoo! ID required)

<*> To change settings via email:
     
    

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU