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.

MSP430FR69891: Question about whether alignment is necessary on the MSP430 for 16-bit values

Part Number: MSP430FR69891


Hello,

I'm experiencing a problem with the design I'm working on which feels like an alignment problem.

Basically, it looks like a global 16-bit value, which is in a structure isn't being written to or read from properly.  I'm wondering if there's an issue with alignment in general, requiring that all variables be aligned on an even address.  I have trouble believing this, and I have yet to find any TI documentation, for the compiler or for the MSP430 which states that alignment is necessary.  The only things aligned to an even address in the MSP430 is the Program Counter and the Stack Pointer.

If anyone knows of any documentation from TI which talks about alignment requirements in the compiler and/or the MSP430 (specifically the MSP430FR6xx Family), I would be very appreciative.  I have googled far and wide, and so far I haven't seen anything from TI yet.

Thank you in advance for any help that anyone can provide.

NOTE: I've also posted this same question in the TI C/C++ Compiler Forum.

Thanks,
Adam

  • Hello,

    As this does sound like a Compiler forum question I would usually send it over to them, but since you already posted it there I am going to keep this thread here for now until you hear back from the Compiler forum. Please comment back here when you receive a response from that forum with any information and let me know if a couple of days pass by and you haven't gotten a response.

    Best regards,

    Matt Calvo
  • Thanks Matt, for your reply.

    I've already got a response from the Compiler Forum on this question, but it's still an open question, and I'll see where it goes from here. I'll definitely update this thread with the replies, and let everyone know when it is closed.

    Thanks again for your response. It's much appreciated.

    Adam
  • I'm all set with this issue, which I've found, fortunately, in the MSP430 firmware code I'm working on.

    Here's what I posted to the Compiler Forum:

    ------------------------------------------------------------------------

    Hello,

    The fundamental reason for the problem I was seeing was due to a #pragma pack( push, 1 ) that was never popped. The reason for the lack of the pop isn't immediately obvious when looking at the code, since it is done in a platform independent manner. The pop for the MSP430 case was somehow forgotten several months ago. And, this problem only mysteriously started to be an issue now. The lack of the packing being popped caused problems with other structures, since they were being packed to 1-byte alignment, when they shouldn't have been.

    So, in summary, I've solved the issue with alignment that I was seeing. Your answer about alignment requirements documented in the Compiler User's Guide, was very helpful.

    If you know where any additional TI documentation describing why the alignment is necessary, that would be very helpful as well.

    Thanks very much for your help.


    Adam

    ------------------------------------------------------------------------

**Attention** This is a public forum