View previous topic :: View next topic |
Author |
Message |
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
Oscillator Problem 18F66K22 Compiler 5.076 HELP |
Posted: Mon Mar 19, 2018 8:56 am |
|
|
Hi,
I meet a problem with an 18F66K22 with which I already realized
a few hundred cards.
To simplify my explanations, I have reduced the final program see below.
1) to check if the program works an LED is present and flashes.
2) I use a crystal of 20Mhz
3) The power supply is a laboratory supply 3.6V 2A limitation for my tests.
4) the realized card uses a LTC 3533 which regulates to 3.3V my tension is displayed on a multimeter FLUKE.
Periodically I do a power ON / OFF and I see this:
The LED flashes more or less rapidly the TEKTRO scope connected to the G0 pin gives me a period of 173ms or 430ms.
A) when the period is 173 ms I can read on the PIN 40 of the 18F66K22 the frequency of 20MHZ.
B) when the period is 430ms on PIN 40 >> NO signal is visible!?
It seems that the internal oscillator turns on once in 2 (ON / OFF of the power supply).
It looks like once in 2
the oscillator changes mode: internal oscillator or Crystal.
Any suggestions or advice are welcome.
Code: |
#include <18F66K22.h>
#FUSES HSH // High speed Osc
//!#FUSES NOBROWNOUT // No brownout reset
#FUSES NOPLLEN // 4X HW PLL disabled, 4X PLL enabled in software
//#FUSES WDT_NOSLEEP // Watch Dog Timer, disabled during SLEEP
#FUSES VREGSLEEP_SW // Ultra low-power regulator is enabled
//#FUSES NOLVP // No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES SOSC_HIGH
#use delay(crystal=20MHZ)
#use rs232(UART1,baud=9600, xmit=PIN_C6,rcv=PIN_C7,errors)
void main()
{
while(TRUE)
{
output_toggle(PIN_G0);
delay_ms(80);
printf(" TEST2\r\n");
}
}
|
Thanks in advance
Cogitum |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 19, 2018 9:49 am |
|
|
Quote: | Periodically I do a power ON / OFF |
1. What is the time delay between power off and power on ?
Is it a very short flick of the switch, or is it several seconds ?
2. Do you have any large capacitors on the board (larger than 1 uF) ?
How many and what capacitance ?
3. What is the estimated total current usage of the board in milliamps ?
4. What happens if you enable Brownout reset ? Does it fix the problem ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Mar 19, 2018 10:57 am |
|
|
While I don't use that PIC , I did download the datasheet for some quick reading...couple of things....
I didn't see the PWT enabled in your 'fuses. I'd have the 'Power Up Timer' enabled,it should allow the PIC to 'nicely' start up.
Also that PIC has a 2 speed start selection, perhaps it's not configured correctly?
Is there a 'large load' attached to the PIC? If so ,perhaps the startup current surge is altering the PIC ? |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
answer |
Posted: Mon Mar 19, 2018 11:48 am |
|
|
Thanks PCM programmer
A1) around 63ms
Veryshort
A2)Yes more than 47µF
A3) Actually few component are on this board
I less than 10 mA
A4) Brownout reset ... no change
One Hardware timer manage the ON/ON by the pin LTC RUN
I'm using the similar PCB (a lot of time) and the same component.
Changed µC, xtal tested with different PS, Li Ion BAT(3.6/4.2V)
I do not understand where is the problem ; hard or soft (both)
Not easy .. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Mon Mar 19, 2018 12:08 pm |
|
|
The master oscillator is not starting, so it is dropping back to the internal oscillator. 8MHz, versus the 20MHz. This is the FSCM settings. So running at 1/2.5 of it's proper speed.
One common thing is that some crystals need a parallel resistor of perhaps 1.5MR to ensure reliable start-up. This is particularly the case if there is a slow rise time on the supply, and some crystals are worse than others here. There is an internal resistor that is meant to do this, but some chip models have this too large to work reliably. This is also why there is a minimum rise rate specified in the data sheet.
Try adding such a resistor. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Mar 19, 2018 12:37 pm |
|
|
I've never liked the 'failsafe OSC' idea...Maybe I'm old but I'd rather the PIC NOT run, then at some 'oddball' speed, where stuff just doesn't 'run right'.
At the very least , perhaps set a bit in an error register, somehow 'flag' the programmer 'I'm not running right'. |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
next |
Posted: Mon Mar 19, 2018 12:37 pm |
|
|
Hi,
Thank you to all of you.
Alas, the addition of a resistance in // on the CRYSTAL did not change the operation.
I'm going to take a break. I will definitely do 2 tests:
1) Change the Crystal (yet a hundred cards work)
2) try to set internal oscillator function (at 16MHZ)
I will come back to give you news after my tests
Regard
Cogitum |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 19, 2018 12:44 pm |
|
|
As another test, remove the 47 uF cap, so there are only the 100 nF
bypass caps left on the board. See if you still get the problem.
Also, describe your MCLR circuit.
With regard to temtronic's question, I compiled the program and PUT
is enabled by default, as shown in bold below:
Quote: | Configuration Fuses:
Word 1: C21C VREGSLEEP_SW INTRC_HP SOSC_HIGH NOXINST HSH NOPLLEN FCMEN IESO
Word 2: 7C76 PUT BROWNOUT BORV20 ZPBORM NOWDT WDT1048576
Word 3: 8901 RTCOSC_T1 CCP2C1 MSSPMSK7 MCLR
Word 4: 0091 STVREN BBSIZ2K NODEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E00F NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 400F NOEBTR NOEBTRB |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19499
|
|
Posted: Mon Mar 19, 2018 1:14 pm |
|
|
The failsafe can be turned off. NOFCMEN.
You could force a reset, by having NOFCMEN and enabling the watchdog (obviously with a suitable interval and restart_wdt in the loop). However if the oscillator is not starting, this would not make it start.
It's very odd that adding a parallel resistor doesn't force an oscillator start. What is the crystal?. Data?.
What capacitors are on it?.
Failure to start is common if the crystal has too much capacitance on it.
I had a similar problem recently, with a batch of SMD crystals whose casings were not properly sealed and they were leaking during board manufacture. When the cases were removed some were full of water.... |
|
|
Cogitum
Joined: 22 Mar 2012 Posts: 70 Location: France (Paris)
|
next |
Posted: Tue Mar 20, 2018 8:19 am |
|
|
Hello everyone,
Following your different remarks and suggestions here is the list of my actions and the result.
1) I use the 18F66K22 on different cards with the same structure for several years without having encountered this type of problem.
2) I measured on a blank PCB the value of the stray capacitances at the point where the crystal capacitors are normally soldered. >> 2pf and 4 pf.
I replaced the 2 capacitors of 12 pf by 2 x 8.2 pf.
3) I added Fuses (see list attached)
4) Placed a small load on the 3.3V (1mA)
5) Time measurement ON / OFF about 1sec.
6) The led (PIN_G0) flashes normally
7) Measurement of the crystal frequency 20Mhz)
8) Realized several ON / OFF manual and auto (every 15mn)
The crystal always oscillates at 20 MHZ!
Note: MCLR: normally R = 47K without capa changed by 10K
Also tested with 100nF and 10K >>> no change
Your help has been invaluable and pushed me into my reflections I thank you warmly for this help.
Cogitum
Code: |
#include <18F66K22.h>
#FUSES HSH // High speed Osc
#FUSES BROWNOUT // No brownout reset
#FUSES NOPLLEN // 4X HW PLL disabled, 4X PLL enabled in software
//#FUSES WDT_NOSLEEP // Watch Dog Timer, disabled during SLEEP
#FUSES VREGSLEEP_SW // Ultra low-power regulator is enabled
//#FUSES NOLVP // No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES BORV20 //Brownout reset at 2.0V
//!#FUSES IESO //Internal External Switch Over mode enabled
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES NOFCMEN //Fail-safe clock monitor disabled
//!#FUSES PUT //Power Up Timer
#FUSES SOSC_HIGH
#use delay(crystal=20MHZ)
#use rs232(UART1,baud=9600, xmit=PIN_C6,rcv=PIN_C7,errors) |
|
|
|
|