I'm working with an embedded C compiler (ARM cortex-m3 chip) and it seems to initialize the wrong value to a struct. Why does this happen? If it's an alignment issue, shouldn't the compiler know to align an int32u to a 4-byte boundary?
Note: the printf merely throws bytes out of the serial port. There is no stdio.h implementation on this chip.
typedef struct
{
int32u startTime;
int16u length;
int32u offTime;
} Cycle;
Cycle cycle =
{
315618000,
1200,
0
};
void init()
{
printf("\r\nInitialized! Cycle Start: %d", cycle.startTime);
cycle.startTime = 315618000;
cycle.length = 1200;
printf(" Cycle Start: %d", cycle.startTime);
}
Output: Initialized! Cycle Start: 631237200 Cycle Start: 315618000
Note:: This NOT a printf issue. The debugger verifies the value in memory as 631237200 as well.