big endian / little endian

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16900
Level 1
Level 1
Hello,

I want to define a union with 32 Bit.

union{
uint8_t x [4];
uint32_t y;
};

In one case I work with "uint32_t y" and in the other with "uint8_t x [4]".

My problem is that uint32_t is little endian but I need big endian. How can I change it?

I use Dave 4 and a XMC 4700 Controller.

Thanks for your help

S.H.
0 Likes
1 Reply
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

XMC4 is implemented as little endian processor. Therefore any uint32_t variable would be stored in memory in little endian format.
You can use the __REV() intrinsic to store a number in a uint32_t in big endian format.

Regards,
Jesus
0 Likes