|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
problem with pointers - strange bug |
Posted: Mon Nov 29, 2004 4:15 pm |
|
|
I am using a PIC18F4620 because of the large memory.
Here is my code. I tried to reproduce the bug using a smaller program than my program.
Code: | #include <18F4620.h>
#device *=16
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,WDT128,LP, NOPROTECT, IESO, BROWNOUT, BORV21, NOPUT, NOCPD, STVREN, NODEBUG, LVP, NOWRT, NOWRTD, NOEBTR, NOCPB, NOEBTRB, NOWRTC, NOWRTB, FCMEN, XINST, PBADEN, LPT1OSC, MCLR |
Code: | void main()
{
unsigned int array[1000];
typedef union myType
{
unsigned int mybyte;
struct _BITS
{
unsigned int value:7;
unsigned int onebit:1;
}bits;
}Type;
Type * ptr = 0x014A;
(*ptr).mybyte = 11;
} |
I really don't need the big array, but I just use it to be able to track what value is at address 0x14A in MPLAB Sim.
The problem is that the instruction (*ptr).mybyte = 11; doesnt change the value at address 0x014A, but changes the value at address 0x004A.
When I set ptr to a smaller value like 0xBE for example, everything works fine. Why doesn't this work with 0x014A.
What can I do to change the value at address 0x014A??? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Nov 29, 2004 6:16 pm |
|
|
|
|
|
Guest
|
|
Posted: Mon Nov 29, 2004 7:49 pm |
|
|
Thanks.
BTW CCS should make sure that this kind of details work.
I mean, what's the difference betwen ptr->mybyte and (*ptr).mybyte ??? |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|