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.

Unsigned Char Ptr MSP430 Confusion

Hi, here is what is probably a very easy question, but I am missing something important as far as programming goes on MSP430s.

The problem has something to do with how ptrs are dereferenced for char data. I know ptrs are 16-bits long. In the code below:

    unsigned char data = 5;
    unsigned char * addr = & data;

I use the debug window to see that the value for addr is 

0x3BDC

Here is a memory view of that address:

What I don't understand is that even though addr is an unsigned char *, the actual data byte (the number "5" in this case), is actually at address

0x3BDD

NOT at the address 0x3BDC which is what the debugger shows:

Can anybody explain why this is? How would I ensure that the unsigned char data byte is actually at the address value specified? (and not the address one byte later)

  • > the actual data byte (the number "5" in this case), is actually at address 0x3BDD

    No, it is not.

    As msp430 is little-endian hardware, word view happen to be deceiving for unaware users:) First you shall switch memory view to byte format to see you are mistaken, then familiarize with byte order. Wiki article is good enough

  • I figured it had something to do with endianness. I'm glad you recognize that word-view with little endian can be deceiving.
  • >I'm glad you recognize that word-view with little endian can be deceiving.
    Only to unaware users who look for bytes using word view. Those who knows endianess - either switch to correct data type or just know where to look for byte in question

**Attention** This is a public forum