Loosing space memory dsPIC33F 16 bits
Example of diagram of memory
Loosing space memory dsPIC33F 16 bits
I think their compilers are GCC based so you can use __attribute__((packed)) on individual structure variables or -fpack-struct compiler switch to pack all structures.
Not a FreeRTOS question, by the way.
Loosing space memory dsPIC33F 16 bits
One comment, on the dsPic Processor, like many processors today, multi-byte numbers may not be placed at arbitrary memory locations, but must be aligned to some power of 2 for addresses. 16 bit numbers on the dsPic must be stored on even addresses or the processor will not fetch them correctly. If you try to access a 16 bit word at an odd address, the processor will raise an address error execption.
Loosing space memory dsPIC33F 16 bits
One comment, on the dsPic Processor, like many processors today, multi-byte numbers may not be placed at arbitrary memory locations, but must be aligned to some power of 2 for addresses. 16 bit numbers on the dsPic must be stored on even addresses or the processor will not fetch them correctly. If you try to access a 16 bit word at an odd address, the processor will raise an address error execption.So the order in which you list the members inside the structure will also make a difference. Dont have a char followed by an int followed by a char, but instead a char followed by a char followed by an int.
Loosing space memory dsPIC33F 16 bits
Int followed by char followed by another char won’t lose space. A structure of an int followed by a char, and that is all, will still take 4 bytes as is required to make array work.
Loosing space memory dsPIC33F 16 bits
Hi edwards3, the tip you said worked very well “__attribute__((packed))”.
My structures are in this syntax:
typedef struct
{
char a;
int b;
char c;
} Tes1; How I put the attribute in this structure above? Because I got it in this syntax below:
struct Test2
{
char a;
int b;
char c;
} __attribute__((__packed__)); typedef struct Test2 Test_2; Result:
sizeof(Tes1) = 6
sizeof(Test_2) = 4
typedef struct
{
char a;
int b;
char c;
} Tes1; How I put the attribute in this structure above? Because I got it in this syntax below:
struct Test2
{
char a;
int b;
char c;
} __attribute__((__packed__)); typedef struct Test2 Test_2; Result:
sizeof(Tes1) = 6
sizeof(Test_2) = 4