It seems to happen fairly often that I'm working on a system that incorporates a serial (SPI or async) command set.
As such, I generally have to put together a set of arbitrary command byte values that represent possible commands.
As such, I seem to find myself trying to maximize the distinction between possible commands. For example, If I have a grand total of 4 commands, I would choose something like:
0x81, 0b10000001 0x42, 0b01000010 0x24, 0b00100100 0X18, 0b00011000
or better yet (as it allows further expansion)
0xA5, 0b10100101 0x5A, 0b01011010 0X99, 0b10011001 0x66, 0b01100110 0x96, 0b10010110 0x69, 0b01101001
Both have the advantage of being both very distinct, so noise has little chance of corrupting one to look like another, and also being possible to (manually) determine the command using only a single logic-analyser or oscilloscope channel.
So, given the assumption that you are designing an arbitrary protocol, and the assumption that noise isn't a significant consideration, What is good advice and/or comments about the best way to choose binary constants for the command definition of a serial interface?
Actually, this seems pretty broadly applicable to any situation where you are using binary commands between two (or more!) systems.