Electronic – PIC pin state change reset the PIC

picreset

I am trying to collect data from analog sensors (temperature and relative humidity) with a PIC microcontroller (PIC18F14K50).
In order to save battery, the supply voltage of the sensors is turned ON when data have to be collected and turned OFF after. The supply voltage is controlled by the pin RB7 of the microcontroller.
The problem is that when the pin RB7 of the PIC goes high, the PIC is reseted, I have tried several software and hardware modifications but the problem remains. I am out of ideas now, may you have any suggestions ?

enter image description here

Note :

  • If RB7 is turned ON at the very beginning of the program and remains ON, there is no reset.
  • The 4MHz crystal and two 15pF capacitor connected to RA4 and RA5 are not shown here
  • I am using a switching voltage regulator to provide the +5V from +9V battery

Best Answer

I would guess, when you connect the +5V_SEC to +5V, there is a transient dip on +5V. That is perceived by the PIC as a brownout. The dip happens because the capacitors connected to +5V_SEC suddenly charge. You can probably see the dip with an oscilloscope.

[I've seen that sort of behavior before. I'll see if I can find the old oscilloscope screenshot.]

On a different note. Add a pull-down resistor from the gate of Q1 to ground. That will ensure that Q1 will not turn on RB7 is high impedance.