PDA

View Full Version : Power Control (PCON) Register



Dick Ivers
- 27th March 2013, 21:37
I have a situation where I need to skip over part of a program if a MCLR reset has occurred. The device is 16F1823. MCLRE is enabled on. The manual says a MCLR reset can be differentiated from a power on reset by observing the bits in the PCON register. The code I tried works some of the time, but is inconsistent and ultra sensitive to noise and grounding conditions. The code section:



if PCON.3 = 0 then 'when mclr reset has occurred
PCON.3 = 1 'set mclr flag
goto current 'jump over data display
endif

Question: Is the PCON register accessible by PBP? Should asm be used for this task instead?

Dick Ivers
- 28th March 2013, 19:21
In answer to own question, of course PCON is accessible by PBP, all registers are. I tried asm and it makes no difference, the sensitivity to noise is still there. The circuit does work some of the time, so this is most likely a hardware issue. I'll keep working on it.

Dick Ivers
- 29th March 2013, 23:15
The following code modification fixes the problem. The idea is a double set of the MCLR reset flag. Electrical noise tends to disrupt the initial condition of the MCLR bit so a double set is needed:


if PCON.1 = 0 then 'when por reset has occurred
PCON.3 = 1 'set mclr flag
PCON.1 = 1 'set por flag
endif

if PCON.3 = 0 then 'when mclr reset has occurred
PCON.3 = 1 'set mclr flag
goto current 'jump over data display
endif

This is working nearly 100% of the time, unless the noise environment is very,very severe.
The fix is posted here for future reference.

AvionicsMaster1
- 2nd April 2013, 02:27
I'm just curious as to what machine is making so much electrical noise that it's affecting your circuit?

Is it time for a new power supply or a few capacitors and a coil?

Are there electrical issues in your other devices?

Like I said, just curious.

SUNFLOWER
- 2nd April 2013, 06:26
Thanks Dick, I am now using this info to control a field of solar micros to stow with central power control -- RCON.1

Dick Ivers
- 3rd April 2013, 16:48
AV1
The system is brushless dc motor control. My project is an energy meter in series with the battery power line. The motor controller generates lots of electrical noise, especially during the startup phase of motor operation.

SUNFLOWER
I'm glad the PCON tactic is working for you.