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 CCS Technical Support

#LOCATE'ing Struct Arrays

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



Joined: 07 Sep 2003
Posts: 4
Location: Texas

View user's profile Send private message

#LOCATE'ing Struct Arrays
PostPosted: Thu Jul 20, 2006 11:17 pm     Reply with quote

I have a struct array that consists of 24 structures of 4 bytes each. My question is does the compiler think that this is a 96 byte continuous array?

I am asking this because if I add another variable to the struct, it will push the entire array outside of 96 bytes usage. This might cause a problem since I have heard that arrays must be continuous within one bank.

To avoid problems right now, I have forced the compiler to place the array in bank 2 (16F876).

I am using PCWH 3.102 (so very old).

Code:
//structures
typedef struct {
   int temp;         //temperature
   int temp_high;    //high temperature
   int temp_low;     //low temperature
   int humid;        //humidity
   //long timestamp;
} DAYRECORD;

//global variables (historical weather information)
DAYRECORD history[24];  //24 hours if daily history
#locate history = 0x110    //must locate this in bank 2 because it is exactly 96 bytes long


Harrison
Ttelmah
Guest







PostPosted: Fri Jul 21, 2006 4:18 am     Reply with quote

Yes. The compiler doesn't just 'think' it is a continuous 96 byte array. It _is_ a continuous 96 byte array!. If you want it to be in seperate items, you would have to handle it differently. Structures are no different from any other data type in this regard...

Best Wishes
epideath



Joined: 07 Jun 2006
Posts: 47

View user's profile Send private message

PostPosted: Fri Jul 21, 2006 9:05 am     Reply with quote

You may want to look at using an external EEPROM to store your data. They are cheap and easy to interface. This would get around the 96 byte limitations. Then you can just read one DAYRECORD at a time or store one.

Regards
hp



Joined: 07 Sep 2003
Posts: 4
Location: Texas

View user's profile Send private message

PostPosted: Fri Jul 21, 2006 10:13 am     Reply with quote

Thanks for the info.

I may try an external eeprom (most likely FRAM since I will be moving the data around alot). For now I have split the one huge array into 2 smaller ones, locating each one to a seperate bank.

Harrison
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