• AVR Freaks

AnsweredHot!PIC16LF1823: How to know when the external oscillator is stable

Author
iRun26.2
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2016/05/05 04:59:30
  • Location: 0
  • Status: offline
2017/06/07 09:44:29 (permalink)
0

PIC16LF1823: How to know when the external oscillator is stable

I am using a PIC16LF1823 PIC microcontroller and I need to switch back and forth between the internal oscillator and my external high speed oscillator.  There are flags to examine to determine when the internal oscillator is stable but I don't know how to verify that my high speed external oscillator is ready.
 
My program is behaving rather erratically and I think it is because I am letting the external oscillator run before it is ready.
 
Any suggestions would be greatly appreciated...
#1
MitYeltu
Senior Member
  • Total Posts : 127
  • Reward points : 0
  • Joined: 2010/02/02 12:05:03
  • Location: TN
  • Status: offline
Re: PIC16LF1823: How to know when the external oscillator is stable 2017/06/07 10:35:12 (permalink)
0
The datasheet (pg 64) reads as follows:
"When switching between clock sources, a delay is required to allow the new clock to stabilize. These oscillator delays are shown in Table 5-1."
 
From table 5-1, I would suggest a 2uS delay before continuing with program execution. unless you are using the PLL, in which case I would suggest 2mS.
 
You might also try using the fail-safe clock monitor. If your crystal is not operating properly, this might detect it.
 
Good luck.
#2
jack@kksound
code tags!
  • Total Posts : 3202
  • Reward points : 0
  • Joined: 2014/05/14 10:03:19
  • Location: 0
  • Status: offline
Re: PIC16LF1823: How to know when the external oscillator is stable 2017/06/07 10:39:31 (permalink) ☼ Best Answerby iRun26.2 2019/08/12 06:32:22
+1 (1)
What mode are you running in when using the external oscillator (HS, LP, etc)? Is it a crystal (which uses the pic oscillator) or an external self-contained oscillator?
#3
coffee critic
Super Member
  • Total Posts : 373
  • Reward points : 0
  • Status: offline
Re: PIC16LF1823: How to know when the external oscillator is stable 2017/06/07 11:00:26 (permalink)
0
The OST is disabled in EC mode but it might be possible to insert a fixed delay from ext oscillator turn on to clock switch to allow the external oscillator to be stable.  OST is available with HS, XT and LP mode of operation.  HS in single ended mode might work but I think it would require the other oscillator pin to be open.  This seems risky to run this way. 

n_*$
#4
RISC
Super Member
  • Total Posts : 5376
  • Reward points : 0
  • Status: offline
Re: PIC16LF1823: How to know when the external oscillator is stable 2017/06/07 12:53:29 (permalink)
+2 (2)
Hi,
As stated above, in case you use the internal PLL, the lock time of the PLL will be the major delay contributor compared to the oscillator stabilization time.
Regards
 
#5
iRun26.2
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2016/05/05 04:59:30
  • Location: 0
  • Status: offline
Re: PIC16LF1823: How to know when the external oscillator is stable 2019/08/12 08:12:05 (permalink)
0
I am using a 20MHz crystal in the HS mode.
post edited by iRun26.2 - 2019/08/12 08:15:45
#6
Jump to:
© 2019 APG vNext Commercial Version 4.5