for (int i = 0; i < msg_size - 2; i++)
{
msg.CS ^= (byte)p*;* } Serial.write(p, msg_size); The output i get over serial ( in hex mode) 53 01 00 02 00 90 01 2A C1 Notice that the output is low byte then high byte of each variable. Why is this? I am running out of cycles on this uC, and fast ways to fix this? Thanks.
It matters because 1 (int) variable consists of two bytes, and i am trying to have two uC pass variables back and forth, and i could run into a problem if on uC expects MSB first but gets LSB. So therfore either way doesn't matter, as long as they both agree on the method.
I had already planed out my comm scheme to be MSB first, and wrote that into the other uC; because well, that just made the most sense to me.
It matters when you have some sort of communications between systems that (might) use different byte orders ("binary" files, networking or other comm link, shared memory, and on 8-bit processors like AVR, perhaps shared data between different languages (asm and C, for example.))
In (somewhat modern) CPUs, most Intel architectures (x86) and chips are "little-endian" (low bytes in low addresses), and most motorola (now Freescale) chips (68xxx) were big-endian. Some CPUs (PPC, MIPS, ARM) can do either one (sometimes based on chip configuration, sometimes based on smaller config (per-process or memory region.))