The following code produces unexpected results depending on which character is chosen for lcd.print from a char array that has up to 9 elements. Four of the locations print as expected, but three of them print the correct data preceded by 6 F's.
Why are the F's showing up for some of the lcd.print's
It looks like it's upgrading the chars to long integers when it does the HEX output. A long has 4 bytes, or 8 hex digits.
Note that char is a signed datatype. If a char has a 1 in the first bit position then it's negative and expanding it out to a long requires 1 to be repeated all the way to the left so that the first bit of the long is also 1. This then comes out as a "F" digit in hex.
If you declare the command[] array to be an array of bytes, then that's unsigned and the sign-extension doesn't happen when it's converted to a different type.
I'm not sure why it's expanding the chars to long.
I can see you are correct. Whenever there is a 1 in the first position it expands to a long. I tried to make the array bytes instead of char but ran into a bunch of type mismatches in other parts of the program that even explicit conversions didn't seem to fix.
I would appreciate it if someone could help find an answer to this problem. Here is the entire code so its all in context.