Well, not so fast. Deleting and rewriting KBI1.C and KBI1.h worked for about two minutes.
Here is the code in question (generated by Processor Expert):
byte KBI1_GetVal(void)
{
byte value = 0x00U;
value |= PTAD & 0x01U;
value |= PTAD & 0x02U;
value |= PTAD & 0x04U;
value |= PTAD & 0x08U;
value |= (byte)((PTBD & 0x04U) << 2);
value |= (byte)((PTBD & 0x08U) << 2);
return value;
}
PTAD is at address zero. If I change "PTAD" to anything else, such as "PTADD" (address 1) or "PTAB" (address 2), it works as expected. If I leave it at PTAD, but select Run instead of Debug, it works perfectly.
This is some of the first code written for this project, and had been working perfectly until recently. I'm using CW for MCU version 11.1, which doesn't appear to have been updated since 2018, so it's probably not new software.