Home Price List Order Info Microcontrollers Assembler C and C++

Making PIC Inputs crash proof


A customer rang me recently to discuss a problem he was having with the EE memory of a PIC16F627 loosing its memory. This is a code generating PIC that he buys in to use in his system. The manufacturers claim that their PIC cannot loose its memory yet my customer finds that when he switches the power on and off several times the code PIC forgets its code. The code is stored in EEPROM and can be changed by holding down an input line and sending the PIC a new code.

Strictly the manufacturer and my customer are both right. The problem is that when the power to the PIC is switched on my customer must ensure that the input which resets the code is always held in the state which stops the code being reset, he is obviously failing to do that. But I agree with my customer that it is up to the designer to ensure that the systems does not fail when misused.

The are a number of ways that the code PIC can be programmed to avoid resetting the code during powerup. The simplest is to test the reset input line twice with a delay of 10 milliseconds or so in between but a better system would be to require two input pulses with a gap of 100 to 250 millisecond between them. This can be done with this sequence.... When the input goes low wait 100 milliseconds then start running round a 250 millisecond timing loop waiting for it to go high. When it goes high run round a different loop keeping the same counter values waiting for it to go low again. If the count runs out at either stage exit from the resetting routine.

With any input which causes an important change it is always better to require the line to go high to get the action. A circuit which is off cannot provide a high.