Re: [3.1]How serial send 0xa5a5 so correctly received & tested in 4byte structure?
- Posted by DerekParnell (admin) Apr 09, 2014
- 2112 views
DanM_anew said...
... I don't understand why you have the #00 pairs following the #A5 pairs rather than interspersed:
constant sync_LE = {#A5, #00, #A5 ,#00}
The simple answer is that that would be a different number.
- A5A5 is the number 42405 in decimal. It takes up a minimum of 2 bytes of RAM (16-bits). The exact amount of RAM depends on how its defined in a program. In the example you gave it was declared as an unsigned 32-bit integer, and thus it gets padded with two bytes of leading zeros to make up the full 32 bits. In a big-endian system, the byte layout of a 32-bit number has the most significant bytes first, thus it would be in RAM as #00 #00 #A5 #A5. In little-endian systems the least significant bytes come first in RAM, so it would look like #A5 #A5 #00 #00.
The {#A5, #00, #A5 ,#00} either repesents the number #00A500A5 or 10813605 (little-endian), or #A500A500 or 2768282880 (big-endian).

