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/
|