• AVR Freaks

AnsweredHot!High accuracy timer in sleep mode

Author
pajuhesh80
New Users
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2019/12/08 11:23:37
  • Location: Nowshahr, Mazandaran, Iran
  • Status: online
2020/01/20 10:14:35 (permalink)
0

High accuracy timer in sleep mode

I need an accurate (millisecond) timer on PIC18F25K50 to run in sleep mode. Datasheet says that I need to use secondary oscillator mode to run timer in sleep mode. I have two questions:
 
1- Datasheet says:
13.4 Secondary Oscillator
A dedicated secondary low-power 32.768 kHz
oscillator circuit is built-in between pins SOSCI (input)
and SOSCO (amplifier output). This internal circuit is to
be used in conjunction with an external 32.768 kHz
crystal.

What is that "circuit"? is it an independent oscillator module that can run even without external crystal and uses crystal for better accuracy? or it needs secondary external crystal?
 
2- 32.768 kHz is great for seconds; but for milliseconds, I need 32.768 timer ticks. So it's not good for milliseconds. Also, datasheet says I have to use 32.768 kHz as secondary oscillator. Any solution?

Slow and Steady!
#1
mbrowning
USNA79
  • Total Posts : 1627
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: online
Re: High accuracy timer in sleep mode 2020/01/20 10:28:24 (permalink)
0
So use a 32 or 36 or 38 or 40KHz crystal. Active clock tuning with SOSC won't work, but so what?
#2
pajuhesh80
New Users
  • Total Posts : 16
  • Reward points : 0
  • Joined: 2019/12/08 11:23:37
  • Location: Nowshahr, Mazandaran, Iran
  • Status: online
Re: High accuracy timer in sleep mode 2020/01/20 10:48:10 (permalink)
0
Is it OK to use crystals other that 32.768 kHz as secondary oscillator? Datasheet says:
This internal circuit is to be used in conjunction with an external 32.768 kHz crystal.

 

Slow and Steady!
#3
ric
Super Member
  • Total Posts : 25502
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: High accuracy timer in sleep mode 2020/01/20 12:33:24 (permalink) ☼ Best Answerby pajuhesh80 2020/02/01 02:51:09
0
pajuhesh80
What is that "circuit"?

It's a buffer that requires an external crystal to run. The text you quoted spells that out.

is it an independent oscillator module that can run even without external crystal and uses crystal for better accuracy? or it needs secondary external crystal?

It needs the crystal.
 

Also, datasheet says I have to use 32.768 kHz as secondary oscillator. Any solution?

32kHz is close enough to 32.768 kHz, that the circuit would work just fine with the alternative value.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
Mysil
Super Member
  • Total Posts : 3619
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: High accuracy timer in sleep mode 2020/01/20 13:14:16 (permalink)
+1 (1)
Hi,
Yes, You may well use a crystal with a different frequency.
The Amplifier  is inside the PIC microcontroller,
it is a linear analog amplifier with  some automatic gain control (AGC) circuit.
The amplifier have a wide frequency range around the nominal frequency,
so will adapt to the resonance frequency of the Crystal that is connected. 
 
The Circuit connected to the oscillator pins shall be the external crystal resonator and 2 small capacitors.
There is Circuit diagram in Oscillator section of the Datasheet.
Circuit for Primary Crystal Oscillator, and Secondary Crystal Oscillator, are the same.
Capacitor values depend upon what capacitor values that was used when the Crystal was trimmed during production. Typical values may be between 9 pF and 22 pF.
If a different capacitor value from what was used when crystal was trimmed, then frequency will be wery slightly different.
 
I have observed a secondary crystal oscillator without anything connected, 
It did oscillate happily, but nowhere near the nominal frequency.
 
It may depend somewhat upon what device type is used,
If you read Datasheet more carefully, examining: Electrical Characteristics chapter,
there may be specification of Frequency range for the Secondary oscillator,
or the Primary oscillator in LP mode.
For PIC18FxxK22 devices, the frequency range is between 5 kHz and 200 kHz.
 
The reason for using 32.768 kHz crystal, is that these are mass-produced for use in digital wristwatches and other clocks, and have low price and good accuracy.
 
It is also possible to connect a complete, self-contained external oscillator.
There are some external MEMS oscillators that promise better accuracy than typical low-cost crystal resonators.
 
Regards,
    Mysil
#5
Jump to:
© 2020 APG vNext Commercial Version 4.5