I found that after running the initialization code some digital inputs have the wrong value for a short time (few tenths of a millisecond). In our case this caused a problem because one of the digital inputs was a trigger to store calibration data in EEPROM. Storing calibration data when not in the correct state was a problem.
I had set up pins 8, 10, 12, 14, 16 as digital inputs. There are supposed to be built-in pull-up resistors so these should read “1” with nothing connected. But in fact 8 and 10 are “1” and 12, 14, 16 are “0” for the first loop of the processing.
Anyway, I found that putting a small delay in the initialization code solves the problem. You can’t put a big delay or you get a blinking red “PROGRAM STATE” light and nothing works.
I used a little spin loop and tried different values. The value below (5000) is more than the minimum needed and much less than what causes the red light, so maybe is safe.
// allow digital inputs to settle after POR
{ long spin;
for(spin=5000; spin>0; spin–);
}
Anybody have similar experience or know a more “elegant” fix?
Bill