For those compilers that do not have a built-in function for swapping a byte's nibbles, a simple user function can be created:
And a couple of function call examples:
Happy coding!
Alexandros
Code C - [expand] 1 2 3 4 unsigned char SwapNibbles (unsigned char x) { return ((x >> 4) & 0x0F) | ((x << 4) & 0xF0); }
And a couple of function call examples:
Code C - [expand] 1 2 3 unsigned char ch1, ch2; ch1 = SwapNibbles(0xA3); //ch1=0x3A ch2 = SwapNibbles(ch1); //ch2=0xA3
Happy coding!
Alexandros