![]() |
digital inputs not valid just after initialization?
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 |
Re: digital inputs not valid just after initialization?
I ran into the same problem.
I handled it a little differently in that rather than delay everything I ignore the inputs for a number of clock ticks after initialization. |
Re: digital inputs not valid just after initialization?
Quote:
|
| All times are GMT -5. The time now is 17:32. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi