Thanks a lot for the answer
Question 1:
For alignement it is confirm that the same structure compile with 13 and 12.1sp1 is not addressing the same way.
example :
struct sMySubStruct
{
unsigned long Var2; // 32 bits
}
struct sMyStruct
{
unsigned short Var1; // 16 bits
struct sMySubStruct Sub;
}
Version 12.1sp1 addressing for Var1 = 0x00078704 and for Var2 = 0x00078706, so the size of Var1 = 2 bytes, no padding
Version 13.0 addressing for Var1 = 0x00078704 and for Var2 = 0x00078708, so the size of Var1 = 4 bytes, with 2 bytes padding
Question 2 :
My output is generating perfectly because I could see it into the buffer in hexadecimal but when you use %.2hhX it generate 4 character long string.
try this
signed char Test_INT8 = -10;
char Buffer[10];
sprintf(Buffer, "%hhi", Test_INT8); // Output = "-10"
scanf(Buffer, "%hhi", &Test_INT8); // Read value is -1 "NOT GOOD"
sprintf(Buffer, "%.2hhX", Test_INT8); // Output = "FFF6" "NOT GOOD" Where asking for only 2 character output length, the good output should be "F6". "F6" it's the good hexadecimal value for -10.
scanf(Buffer, "%2hhX", &Test_INT8); // Read value is 0 "NOT GOOD"
And I use those functions sprintf and sscanf with hexadecimal output because of the bug in the question 1, I want to use this method to get rid of alignement problem and automatic padding, to serialize structure to save it into flash or eeprom with the smallest amount of bytes possible. Because the lowest access time possible because we have an interrupt each 66.6us and we should read this structure.
And finally I bypass all the alt library of altera because the are to big and to slow, we don't need this abstraction layer, the code is bigger with and slower.
All the peripheral are access directly, I have 17 years of coding experience in embedded system for high speed acquisition system.