PDA

View Full Version : How long does it take for an 8 bit PIC to stabilize after Power-up?



vintagecarguy
- 23rd March 2015, 07:29
I searched the FAQ's and didn't find an answer so here goes. We have an application that's
currently using an NE556 and several transistors and resistors for timing and logic that we'd
like to replace with a 12F629 using the 4MHz internal clock. We have experience with the
12F629 but the external power to an LM7805 in this application is cycled on and off every 1.2 seconds.

We need to generate a pulse within 50 milli-seconds of power-up; 50 milli-seconds seems like a long time.
Looking at the datasheet, the Oscillation Start-up Timer Period is 25 micro-seconds using the 4MHz
internal clock which looks fine; the Power-up Timer Period is 132 milli-seconds which is a problem. Does the
Power-up Timer Period apply here - i.e. does it take 132 milli-seconds to stabilize?

Thanks,

Craig

Art
- 23rd March 2015, 08:54
I imagine the power up timer is to wait for the crystal frequency to be stable, and that you could disable it
if you had an external clock source continually running (not in your case).
You could use a reset circuit (a resistor and a capacitor) on the MCLR pin to make a shorter reset time.

towlerg
- 23rd March 2015, 14:33
Pretty sure the PWRT is belt and braces. If you don't need to startup in the minimum time and want to be completely stable.

What would be the effect of a few clock cycles long/short slow/fast whatever?

George

George

vintagecarguy
- 23rd March 2015, 18:51
I imagine the power up timer is to wait for the crystal frequency to be stable, and that you could disable it
if you had an external clock source continually running (not in your case).
You could use a reset circuit (a resistor and a capacitor) on the MCLR pin to make a shorter reset time.
Thanks for the suggestion. I had considered adding a supercap to the power supply but didn't think to add a capacitor to the MCLR pin to retain the charge and prevent a reset.

Craig

Art
- 24th March 2015, 15:36
That’s actually not what I was suggesting, but instead to disable the powerup timer which usually holds MCLR,
and use the MCLR pin yourself that will lower the power up time to what is acceptable with a stock reset circuit
consisting of a resistor and capacitor. But if you can use a cap on the supply, the thing I’m working on now
continues to multiplex a display for a couple of seconds after power off with two 470uF caps.

towlerg
- 24th March 2015, 16:59
I had a quick look at the datasheet and I see that the Oscillator Start-up Timer is not invoked if an internal clock is selected. I couldn't find a figure for how long the internal clock takes to stabilize but the "Oscillator Wake-up from Sleep start-up time" is 8us (worst case)

I think it's important to note that the power up timer is optional, so MC must forsee a situation where it is not used.

If you believe that some delay after power up is necessary, Art's idea is the way to go.

if you have space, how about a string of NOPs at the reset vector?

George

How long is the power off for?

Art
- 25th March 2015, 05:33
Interesting, I’d have thought it’s the internal RC clock that would be the option wanting to be stabilised,
but really don’t know how the startup of either clock really looks on a scope, etc.

towlerg
- 25th March 2015, 15:02
I’d have thought it’s the internal RC clock that would be the option wanting to be stabilised
Do you have any basis for that or is it just agut feeling? Is it an RC clock? I can't find in the datasheet what kind of osc the internal 4Mhz clock is, perhaps I didn't look hard enough.

Seems to me the internal osc is physically closer, has optimal caps, and a load of other things I can't think of.

Anyway I think your idea of using an RC to hold MCRL for a short while is vcg's only option if he is uncomfortable turning off PWRT (which he has to to achieve 50Ms reliably).

George

Art
- 31st March 2015, 14:00
it’s more than a feeling that it’s an RC clock.
You would rarely need any external clock if it were any better, the clock wouldn’t need a calibration value,
and the clock wouldn’t run faster if the chip is powered from a higher than spec voltage.
It’s only a feeling that an RC clock would take the longest time to stabilise than any other option.

towlerg
- 31st March 2015, 15:19
Looked in Mid-range family MCU ref manual and you're right, it is an RC clock.

Having read the blurb I was surprised to find that although devices have a calibration value written to them, it is the responsibility of the application to fetch that value and write to the appropriate register.

George

Art
- 31st March 2015, 16:08
Last edited by towlerg; Today at 00:38. Reason: old and stupid
That’s a bit rough!

It will loose time with temperature, and any supply voltage fluctuation (batteries).
It’s ultra cheap, you can use serial, but not keep or measure time with it.

Art
- 31st March 2015, 16:18
That’s an interesting find.
You could probably cycle the calibration value at run time then.


for value = mincalvalue to maxcalvalue
calvalue = value
turn led on
pause
turn led off
pause
next value

You could probably calibrate it yourself with a good freq counter,
and double check their work or what they thought was operating temperature.

Demon
- 7th October 2024, 05:36
Does anyone have an answer to the original question?


How long does it take for an 8 bit PIC to stabilize after Power-up?

I'm trying to clean up code and wondering just how much we should pause at program start. I have code with pauses of all sorts of lengths.

How about:
- without LCD
- with standard 4x20 LCD

16F18877, also an 8-bit PIC.

richard
- 7th October 2024, 07:24
How about:
- without LCD
- with standard 4x20 LCD


a pic is ready as soon as its osc is stable; as discoverable from the oscstat reg, a handful of microseconds at worst
a LCD can take 100's of milliseconds, 500 not uncommon. its not the same across version/model/maker either
its usually pretty obvious when you have tried to talk to a LCD before its listening

i feel you have the cart before the horse

Ioannis
- 7th October 2024, 08:22
Up to this moment I did not had any special needs for a fast power up, so the 1 sec pause worked just fine for me.

But I am pretty sure that each osc will have its own time to stabilise. So, for 18877, page 112 of the datasheet, says that there is a timer named OST (Oscillator Startup Timer) that counts 1024 cycles of from OSC1, if the Oscillator is set to LP, XT or HS (all these are external oscillators).

For any case of oscillator selection (internal or external), there is OSCSTAT register that displays the status of that module in the appropriate bits (page 122).

Page 603 shows the wake up time that any osc selection needs.

Other PIC have same data also, so you may look accordingly.

Ioannis

Demon
- 8th October 2024, 03:15
...Page 603 shows the wake up time that any osc selection needs...

HFINTOSC is typically 11usec to 20usec max (I don't sleep the PIC)

So PAUSE 1 should be more than sufficient for a PIC without LCDs...?

(I wouldn't bother with PAUSEUS if I don't have to).


Using:


#CONFIG
__config _CONFIG1, _FEXTOSC_OFF & _RSTOSC_HFINT32 & _CLKOUTEN_OFF & _CSWEN_OFF & _FCMEN_ON
__config _CONFIG2, _MCLRE_ON & _PWRTE_OFF & _LPBOREN_OFF & _BOREN_ON & _BORV_LO & _ZCD_OFF & _PPS1WAY_OFF & _STVREN_ON & _DEBUG_OFF
__config _CONFIG3, _WDTCPS_WDTCPS_11 & _WDTE_OFF & _WDTCWS_WDTCWS_7 & _WDTCCS_LFINTOSC
__config _CONFIG4, _WRT_OFF & _SCANE_available & _LVP_OFF
__config _CONFIG5, _CP_OFF & _CPD_OFF
#ENDCONFIG

Ioannis
- 8th October 2024, 07:59
If you do not have any LCDs or other peripherals that need time to settle, I am sure that you do not need any delay in your program. If the program reached the first command then the PIC just woke up!

The problem is with other circuits connected to the PIC and are still under Reset period. PIC will not be able to communicate with this only device.

Ioannis

Demon
- 8th October 2024, 12:57
Yeah, hadn't put any thought into MCP23017 requirements.

Gonna have to look at those datasheets.