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.

MSP430FR2476: Is msp430fr2476 little endian?

Part Number: MSP430FR2476


Hi,

Is msp430fr2476 little-endian?

I have used earlier MSP430g-series & it was Little endian. All documents I could find is showing msp430 is little-endian. 

I run the below code in MSP430FR2476 and attached the result.

#include <msp430.h> 
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

/**
 * main.c
 */
int main(void)
{
	WDTCTL = WDTPW | WDTHOLD;	// stop watchdog timer
	volatile uint8_t arr[5] = {0x88, 0x77, 0x66, 0x55};

	    volatile uint16_t byte_2,byte_1;

	    byte_2 = (uint16_t)( *((uint16_t *)&arr[1]) );

	    if(byte_2)
	       byte_1=0;

	    while (1)
	        ;
	return 0;
}

If MSP430FR2476 is little-endian.  In the above image variable "byte_2" should be 0x6677 but it is showing 0x7788. 

Am I missing something?

  • Your mistake is trying to access an integer from an odd address. Unless the compiler implements the extra instructions to build an integer from an unaligned address, (a rare thing) you will always get that result. The lsb of the address is always zero for an integer access.

    Some processors have the hardware to do unaligned accesses automatically but the MSP430 is not one of them.

  • My bad, thanks for the answer @, I got confused when I run the same code on my PC it was able to give 0x6677.

    As you said MSP430 is not doing unaligned addresses. If I try to access an even address it's working.

    Thanks V

**Attention** This is a public forum