I am taking over an old project using TI C2000. Compiled all fine, set break points, stepping through no problem.
Until I found a weird problem today: I defined an unsigned char variable, but can get a simple calculation right. I set a break point, and found out compiler made it into a 16 bit variable.
But 8 bit array is compiled as 8 bit no problem.
If I treat it as a 16 bit in the software, everything is fine. But I never run into this type of issue before.
Source code is here:
//check CRC
unsigned char buf[4];
unsigned char crc;
buf[0] = commandWord >> 8;
buf[1] = commandWord & 0xff;
buf[2] = data[0] >> 8;
buf[3] = data[0] & 0xff;
crc = crc8(buf, 4);
if (0xf000U == (safetyWord & 0xf000U)) {
if ((crc & 0x00ff) == (safetyWord & 0x00ff)) {
ret = TLE_SUCCESS;
} else {
ret = -1;
}
} else {
ret = -1;
}
I had to use crc & 0x00ff to make the software work.
