Electronic – What does a reset of a PIC microcontroller via MCLR actually clear

microcontrollerpic

I'm working on a project that uses a PIC18F26K22 microcontroller, and it's behaving oddly.

Basically, sometimes if you kind of "bounce" on the reset line (I have a button on it, and I just kind of fiddle with it), it will reset and some of the interrupts will not be functional (in this case, the EUSART RX interrupt).

The reset button has a debouncing capacitor to ground, and a pull up resistor (10n/10K respectively).

I've tried adding some precautionary cleanup to the startup section of the source, but it hasn't helped. At this point, I have a manual watchdog that detects a lack of serial traffic, and manually triggers another CPU reset, at which point everything starts working correctly.

My assumption was that the registers on the chip were all reset to their "power-on" state when a reset was triggered (excepting perhaps the RCON register), but the fact that I can fairly reliably trigger strange behaviour by just resetting the chip multiple times quickly makes me think this is not true.

Is corruption of registers triggered by repeated reset a common (or even extant) thing with PICs? I'm mostly familiar with AVRs.


Edit: I considered switch-bounce, but the documentation for the MCLR input states:

These devices have a noise filter in
the MCLR Reset path which detects and ignores small
pulses.

My assumption here was that reset pulses shorter then the minimum width (2 uS, for this part) would be ignored.


Further edit: I've actually looked at the MCLR line with a scope. It is both bounce-free, and entirely satisfies the minimum hold time (the shortest period I saw was ~50 milliseconds, the minimum hold time is 2 microseconds). It's not MCLR bounce.

Best Answer

The reset states of all the registers are very well documented in the datasheet. That tells you exactly what you can rely on being set a certain way versus unknown after a reset. In general though, it is a good idea to explicitly set any special function register values that rely on.

Another problem might be bouncing on the reset line. Look at the electrical spec for the minimum timing of a reset pulse. You may be violating it, especially considering mechanical switches bounce and therefore can produce arbitrarily short pulses during the bounce period.

One way to deal with this is to have the switch short a cap to ground. The line will go low quickly, but after that it will take some minimum time for the switch to be open before the cap voltage rises to the minimum possible high level of the reset pin. If you do this, make sure to put a resistor between the cap (and the switch and its pullup) and MCLR. That allows a programmer to still drive MCLR as it needs to. Some PICs require fast rise times on MCLR during programming, which a cap directly on the pin prevents.