- This topic has 1 reply, 1 voice, and was last updated 11 years, 1 month ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
Microcontroller › AVR › Structures and Memory
I have a project that has a structure that is 2087 bytes in size. I am using pointers to arrays in this structure. I am getting weird values. I think the structure is not stored in memory in a linear format and causing the problems. When I use a structure in PC programs I write there are #pragma commands I use so the data is linear. Example…
#pragma pack(push,1)
struct Data {
uint16_t myArray[10][12];
uint16_t xCnt;
uint16_t yCnt;
//…………….
//……………..
}dat;
#pragma pack(pop)
Is there some way to make the Mega2560 I am using to do this, or is there some other reason for the problems.
This is how the pointer to array in structure is used.
uint16_t offset;
offset = Interpolate3D((uint16_t *)&dat.myArray, dat.xCnt, dat.yCnt, 120, 247);
//
uint16_t interpVal;
//…………………….
//……………………….
return interpVal;
}
Ray.
I was looking in the wrong area for the cause of this problem. The real cause is the structure data being corrupt. The struct data is stored in an external data flash chip. Either during the reading or writing to the chip the data is getting corrupt.
Ray.