News:

Let's find out together what makes a PIC Tick!

Main Menu

Pic failling to start

Started by Yves, Jul 06, 2023, 05:52 AM

Previous topic - Next topic

Yves

Hello group,

I have notice that sometime Pic  fails to start particularly if the power supply has a smooth start like modern laboratory power supply.  I found the pic which is a 18F26k22 doesn't start if the power is applied by pressing the on/off button from the power supply but never fail if the power is connected manually connected by jumping the power wire. it is an issue as I need a a very smooth supply as precision analogue is involve on my project. Is there a trick to get quartz (20Mhz) the oscillator to start all the time?

Regards,

Yves
Yves

John Lawton

Are you sure the oscillator isn't starting, or is it a PIC reset issue?
Do you have low voltage reset enabled?
What is your circuit on the /MCLR pin?

Yves

My MCLR is tide up to the positive supply with a 2.2k resistor. I don't think I have a low voltage reset enable. Can you please elaborate how do do this?

Yves
Yves

SCV

Check you have the correct fuse set for the crystal, HS for 20Mhz.

Yves

I have FOSC = HSHP as suggested for frequency higher than 16Mhz also the quartz is decouple with 2 by 22pF capacitors

Yves
Yves

top204

#5
Try the fuse settings below:

'----------------------------------------------------------------------------------
' Setup the fuses for a PIC16F26K22 device, to operate over 16MHz using an external crystal
'
Config_Start
    PLLCFG = Off            ' Oscillator not multiplied by 4
    FOSC = HSHP             ' HS oscillator (high power > 16 MHz)
    Debug = Off             ' Background debugger disabled. RB6 and RB7 configured as general purpose I/O pins
    WDTEN = Off             ' WDT disabled (control is placed on SWDTEN bit)
    XINST = Off             ' Disabled
    FCMEN = On              ' Fail-Safe Clock Monitor enabled
    IESO = Off              ' Oscillator Switchover mode disabled
    PWRTEN = On             ' PWRT enabled
    BOREN = On              ' Brown-out Reset enabled and controlled by software (SBOREN is enabled)
    BORV = 190              ' VBOR set to 1.9 V nominal
    WDTPS = 128             ' Watchdog ratio 1:128
    MCLRE = EXTMCLR         ' MCLR pin enabled, RE3 input pin disabled
    HFOFST = Off            ' The system clock is held off until the HF-INTOSC is stable.
    PRICLKEN = On           ' Primary clock enabled
    PBADEN = Off            ' PORTB<4:0> pins are configured as digital I/O on Reset
    CCP2MX = PORTC1         ' CCP2 input/output is multiplexed with RC1
    CCP3MX = PORTB5         ' P3A/CCP3 input/output is multiplexed with RB5
    T3CMX = PORTC0          ' T3CKI is on RC0
    P2BMX = PORTB5          ' P2B is on RB5
    STVREN = On             ' Stack full/underflow will cause Reset
    LVP = Off               ' Single-Supply ICSP disabled
    CP0 = Off               ' Block 0 (000800-001FFF) not code-protected
    CP1 = Off               ' Block 1 (002000-003FFF) not code-protected
    CPB = Off               ' Boot block (000000-0007FF) not code-protected
    CPD = Off               ' Data EEPROM not code-protected
    WRT0 = Off              ' Block 0 (000800-001FFF) not write-protected
    WRT1 = Off              ' Block 1 (002000-003FFF) not write-protected
    WRTB = Off              ' Boot block (000000-0007FF) not write-protected
    WRTC = Off              ' Configuration registers (300000-3000FF) not write-protected
    WRTD = Off              ' Data EEPROM not write-protected
    EBTR0 = Off             ' Block 0 (000800-001FFF) not protected from table reads executed in other blocks
    EBTR1 = Off             ' Block 1 (002000-003FFF) not protected from table reads executed in other blocks
    EBTRB = Off             ' Boot block (000000-0007FF) not protected from table reads executed in other blocks
Config_End

To set the device to operate at 64MHz with an external 16MHz crystal, change the line:

PLLCFG = Off

to

PLLCFG = On

Also, add a 100nF capacitor from the MCLR pin to Gnd. This produces a reset until the capacitor is fully charged. I would also change the 2.2K Ohm resistor to a 4.7K Ohm value, so the programmer can supply enough voltage to trigger a full programming mode, and not be pulled too much.

david

If the power supply is a soft start you may not be getting the minimum Vdd rise rate required for a RC dynamic reset.  The attached indicates a minimum of 0.05V/mS so for a 5V rail you would have to be settled within 1/10Sec otherwise there's no guaranteed reset.
Much the same happens during a bad brownout situation where the mains flutters and then restores but some equipment doesn't come up.  Modems are notorious for this and it indicates poor brownout testing during design.

Cheers,
David

John Lawton

Les,

like you I have a similar network that has never knowingly given any problems, but consulting the datasheet for your particular device is highly recommended. See the attached network where a 330R isolates the programmer /MCLR from the 100nF capacitor. Microchip recommended this idea some time ago and I've kept using it.

david

#8
Recommended circuit for slow Vdd rise rates.  Not sure why they include this as it would still need to comply with the minimum rise rate specification.  ???

John Lawton

The range of values used shows to me that the network isn't usually super-critical :)

david

Provided your Vdd is stable before the MCLR pin starts to rise.  This is the issue with dynamic reset - if the Vdd rate rise is slow enough both will arrive at the same time.

tumbleweed

Try using the following config settings and see if that helps
    PWRTEN = ON        ' Power up timer enabled
    BOREN = SBORDIS    ' Brown-out Reset enabled in hardware only (SBOREN is disabled)
    BORV = 285         ' VBOR set to 2.85 V nominal
    MCLRE = EXTMCLR    ' MCLR pin enabled, RE3 input pin disabled
Enabling the Brown-out reset voltage to a higher level may help

trastikata

I see Les has disabled the Two-Speed Start-up. I usually leave it on and first thing in the program I do is to issue some delay to give enough time for the PLL to stabilize.

Does it make sense or it is just some other old habit for things that Microchip advertise but you never need?

Yves

@trastikata,

I have added the capacitor and changed the resistor as per Less's suggestion but still have the problem. The oscillator starts only when Reset The MCLR. Maybe I shouldn't use a 20 Mhz as crystal?
I read and tried to understand from the pdf how Two-Speed Start-up works but for me it is as clear as vegetable soup. Did you worked out how it works? What I understood is is the chip (18F26k22) starts with the internal OSC then sleep to give enough time to the external to stabilize then the external OSC is taking over. One may say to use the internal OSC but I can't do that as my application is very time critical and I can't have the temperature variation of the internal OSC which I believe is much higher than the crystal.

Yves     
Yves

tumbleweed

With 20MHz I find that 15pf usually works better, but that depends on your xtal specs.

trastikata

#15
Quote from: Yves on Jul 06, 2023, 06:39 PMI read and tried to understand from the pdf how Two-Speed Start-up works but for me it is as clear as vegetable soup. Did you worked out how it works?

Yves, the Two-Speed Start-up is very straightforward and in theory excellent function. The chip runs using the internal RC oscillator and then switches to HS crystal when the PLL is locked and the oscillator is stable.

But what I meant about doubting its usefulness was that the HS crystal either works or doesn't oscillate.

Then the only advantage of the Two-Speed Start-up that I see is to give some alarm after a timeout with the HS unable to run.   

I agree with tumbleweed a 12 to 18 pf caps are more suitable for 20 MHz crystal.

However I'd suggest trying a 1 MOhm resistor in parallel with the crystal to help starting the oscillator.

Edit:

Re-reading the OP, I would suggest an inexpensive 1$ TCXO as a clock source.

Yves

Thank You. I will start warming up the soldering iron tomorrow. I will short the crystal first with 1MOhm and if that still not work I will change the caps to the lower values plus adding the 1MOhm as suggested. I Will let you know the outcome. Many thanks again.

Yves
 
Yves

John Lawton

Yves,
please tell us more about your PIC circuit:
Is it on a pcb with a ground (0V) plane or at least good earth tracking?
Are there the recommended bypass capacitors on the power pins?
Is the crystal mounted near to the PIC with short tracks?
Is your crystal compatible with the PIC?
What voltage is the PIC running on?

The PIC datasheet suggests various application notes for crystal selection and oscillator design:
AN826, Oscillator Basics and crystal selection
AN849, Basic oscillator design
AN943, Practica PIC oscillator analysis
AN949, Make your oscillator work

I hope that is of some help.

John

Yves

Too all,
At long last things works now. I follow up Trastikata suggestion to shunt the crystal with 1MOhm resistor and Tumbleweed registers modifications as:

PWRTEN = ON        ' Power up timer enabled
    BOREN = SBORDIS    ' Brown-out Reset enabled in hardware only (SBOREN is disabled)
    BORV = 285         ' VBOR set to 2.85 V nominal
    MCLRE = EXTMCLR    ' MCLR pin enabled, RE3 input pin disabled

I didn't changed the "over size" 22pF capacitors but added a 100nF to decouple the MCLR as suggested from Less.
Now the OSC starts every time. That will be taken in account for the future of new board design.
I must thank everyone in this forum, it was for me a very instructive exercise. You are the best.

Regards,

Yves 
Yves