This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Question on packed Data (__packed)

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++;
		}
	}
}

0