Hello, sorry for my pure english.
I have some little problem when try write to unaligned variable.
Source code, in compiler option -gcc is enabled:
struct __attribute__ ((__packed__)) S1
{
char ID;
short X;
long Y;
};
S1 mystruct;
int main(void)
{
mystruct.ID = 0x77;
mystruct.X = 0x4477;
mystruct.Y = 0x11223344;
return 0;
}
I debug it directly in CCSv5.3, so, on "mystruct.X = 0x4477;" it fails, with data abort exception (address 0x14010, it's ROM code dead loop)
Assembler, that i see in debug:
main:
40200c2c: E59F0024 LDR R0, $C$CON1
40200c30: E3A0C077 MOV R12, #119
40200c34: E5C0C000 STRB R12, [R0]
16 mystruct.X = 0x4477;
40200c38: E59F001C LDR R0, $C$CON2
40200c3c: E304C477 MOVW R12, #17527
40200c40: E1C0C0B0 STRH R12, [R0] <= after this instruction - exception
17 mystruct.Y = 0x11223344;
40200c44: E59F0014 LDR R0, $C$CON3
40200c48: E59FC014 LDR R12, $C$CON4
40200c4c: E580C000 STR R12, [R0]
19 return 0;
40200c50: E3A00000 MOV R0, #0
"A" bit in cp15 is clear, and this code fail with any "A"-bit value...Whats wrong, what i need to do for unaligned correct access?
If the processor doesn't support this access, how to "talk" compiler - generate code with always unaligned access?
CCS arm compiler ignored option "--no_unaligned_access"...