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
Posted: Fri Jul 21, 2006 4:18 am
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
Posted: Fri Jul 21, 2006 9:05 am
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
Posted: Fri Jul 21, 2006 10:13 am
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.
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