ts-7000
[Top] [All Lists]

Re: [ts-7000] pointer weirdness

To:
Subject: Re: [ts-7000] pointer weirdness
From: "Stephen Queen" <>
Date: Wed, 12 Sep 2007 17:42:50 -0600


On 9/12/07, Stephen Queen <> wrote:


On 9/12/07, Yan Seiner <> wrote:

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

Maybe I'm missing something here.

It looks like to me, the way you have things cast, that
*qddr
will give you the 16 bit contents of the object pointed to by qaddr, while
*((uint32_t *)(qddr))
will cast qadd to 32 bits and then give you the 16 bit contents of the object pointed to by the 32 bit pointer.
Do you mean
(uint32_t)(*qddr)
????

Stephen Queen

Never mind, a little bit slow today.
Stephen Queen


__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<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