ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: Problem with DIO1 on TS7300

To:
Subject: Re: [ts-7000] Re: Problem with DIO1 on TS7300
From: "Alvaro Aguirre" <>
Date: Wed, 15 Nov 2006 01:05:49 -0300
That answer my question... thank you Phil!

On 11/14/06, Phil <> wrote:

Hi Alvaro,

Just to let you know why that code fixed your problem, it has to do
with the way pointers work.

In the first code listing you had, "offset" defined as an int
pointer. Then when you were assigning the various PBDR, PFDR, etc
pointers, you were using a line like: PBDR = (offset + 0x04). What
is happening is because the compiler knows that offset is a pointer
to an int, the statement above tells the compiler to set PBDR to
point to the int "4 ints" past offset. Because an int is 2 bytes
wide, this results in PBDR pointing to the "8th byte" past offset
(and the 9th to since PBDR is also an int pointer). Therefore, if
you want that "+ 0x04" to mean plus 4 "bytes", offset has to be a
pointer to a type that is only a "byte" wide, or as in your final
code a void pointer which defaults to byte-wide pointer arithmetic.

You original code should work fine if you change

volatile unsigned int *PBDR, *PFDR;
volatile unsigned int *PBDDR, *PFDDR, *GPIOBDB, *GPIOFDB;
int *offset;

to....

volatile unsigned char *PBDR, *PFDR;
volatile unsigned char *PBDDR, *PFDDR, *GPIOBDB, *GPIOFDB;
volatile unsigned char *offset;

Aren't pointers fun?

Cheers
Phil

--- In ts-7000%40yahoogroups.com, "Alvaro Aguirre"
>
> I solved it... I'm not so sure what's the difference but I paste
the code if
> anyone in the future has the same problem. I get the answer on
> http://www.simtec.co.uk/appnotes/AN0014/ .


__._,_.___


SPONSORED LINKS
Single board computer Hardware Computer running slow
Linux os Single board

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