 | Discussion Forum |  |
|
|
Question on packed Data (__packed)Next Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Eugen Mailaender Posted 13-Sep-2005 16:00 GMT Toolset None |  Question on packed Data (__packed) Eugen Mailaender Hallo i need to store a big amount of data in RAM. If i use __packed, no gap's are inserted and the use of memory is optimized, but working with this data, the program hangs because the program attempts to access Non-Aligned data. My question: How can i inform the compiler to use this data in the correct way. In the Help (variable Alignment) i found: Objects defined with __packed keyword are read and written using byte instructions. Please see the sample program.
Can you help me? Thanks Eugen
#include "AT91SAM7S256.h"
#define RECORDS 10
#define POINTS 45
struct Test
{
int Temperature : 10;
int Humidity : 10;
int Rain : 12;
};
struct struStatistic
{
struct Test Test[POINTS];
unsigned char Wind[POINTS];
} __packed;
struct struStatistic Statistic[RECORDS];
void main(void)
{
int Point, Rec;
for (Rec=0; Rec<RECORDS; Rec++)
{
for (Point=0; Point<RECORDS; Point++)
{
Statistic[Rec].Wind[Point]++;
Statistic[Rec].Test[Point].Temperature++;
}
}
}
| |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|