This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TMS320F28035: Data alignment ?

Part Number: TMS320F28035

Tool/software: TI C/C++ Compiler

Hi,

As you can see on the pictures below, I try to get information from a pointer (value3) but information stored inside variable (value2) is wrong.

After memory analysis, I think that it is a problem with alignment but I'm not sure! Could you explained to me the problem and how to resolve it?

Best regards,

Martial

  • The compiler insures that every long variable is aligned to a 2 word (32-bit) boundary.  It presumes every pointer to a long is aligned.

    When you write an expression like ...

    ptr_to_u32 = (uint32_t *)&array[i];

    It is the user's responsibility to make sure the alignment requirements are met.  If that is an array of ints, and i contains an odd value, then the alignment requirement is not met.

    I suspect something similar is happening in your case.

    Thanks and regards,

    -George

  • Thanks for the answer !

    Martial