View previous topic :: View next topic |
Author |
Message |
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
#FUSE NOMCLR question |
Posted: Fri Oct 12, 2018 1:01 pm |
|
|
I have question about MCLR pin.
As I understand this pin is to make PIC work more stable during "power on" but what is happening when I use #FUSE NOMCLR.
If I use MCLR pin during power on, when MCLR pin voltage is high enough starts program and before program starting PIC clears all registers including Program Logic Counter.
But when #FUSE NOMCLR is in code how to ensure that PIC clears all registers? I have #FUSE NOMCLR in my code because I am prototyping circuit on Mini Prototype Printed Circuit Board Breadboard and I suspect that without MCLR pin connected to voltage PIC starts its work in the place that it stopped before power off. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 12, 2018 6:12 pm |
|
|
MCLR is still connected to Vdd internally:
Quote: |
Device Configuration Bits - PICmicro Mid-Range MCU Family
MCLRE: MCLR Pin Function Select bit
1 = Pin’s function is MCLR
0 = Pin’s function is as a digital I/O. MCLR is internally tied to VDD. |
http://ww1.microchip.com/downloads/en/DeviceDoc/31027a.pdf |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Fri Oct 12, 2018 10:52 pm |
|
|
and the chip RAM cannot hold anything without power.
The data sheet shows the power on state for all the SFR's. The RAM is indeterminate.
Without an external MCLR connection, the chip will generally wake _earlier_ as the power rises. This can result in unexpected results if (for instance) the supply rises slowly, or the code starts to do things before the supply is genuinely stable. This is down to the code making sure it allows time for this to happen.... |
|
|
silelis
Joined: 12 Jun 2007 Posts: 68 Location: Poland, podlaskie district
|
|
Posted: Fri Oct 12, 2018 11:07 pm |
|
|
I agree that RAM and registers can not hold data without power.
Because there is no MCLR pin I added the the beginning delay_ms(1500); but next command output_high(pin_b5); (as tested) is executed after huge amount of time.
Probably I will make in prototype board MCLR circuit but wonder what with small 8 pins PICs. In some cases there is no possibility to put there MCPL so as You say the only solution is delay at the beginning. But from Your experience how long? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 12, 2018 11:33 pm |
|
|
Post your PIC and a description of your power supply circuit. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19535
|
|
Posted: Sat Oct 13, 2018 1:33 am |
|
|
Big question is how fast your power supply rail rises?.
There is a specification for the slowest rate this can rise, for the internal reset circuitry to work properly in the data sheet (for most PIC's). If this is not met, and there is not an external MCLR signal, then the registers may not properly reset.
Any normal supply will have no problems.
However if you have something huge like a 4700uF reservoir capacitor and a supply limited to only delivering a few tens of mA, then problems.
For example PIC18F4520. Data sheet. Electrical characteristics
D004
VDD Rise Rate
to ensure internal
Power-on Reset signal
0.05 V/ms.
So a 5v rail would have to get up to 5v, in less than 100mSec. |
|
|
|