CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

problem with pointers - strange bug

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








problem with pointers - strange bug
PostPosted: Mon Nov 29, 2004 4:15 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Mon Nov 29, 2004 6:16 pm     Reply with quote

Code:
   ptr->mybyte = 11;
Guest








PostPosted: Mon Nov 29, 2004 7:49 pm     Reply with quote

Thanks.
BTW CCS should make sure that this kind of details work.

I mean, what's the difference betwen ptr->mybyte and (*ptr).mybyte ???
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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