ts-7000
[Top] [All Lists]

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

To:
Subject: [ts-7000] Re: Problem with DIO1 on TS7300
From: "Phil" <>
Date: Wed, 15 Nov 2006 00:51:54 -0000
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  "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/ .






 
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