View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
How to adjust the RTC of 24FJ64GA306 |
Posted: Sat Jan 04, 2014 11:53 am |
|
|
Greetings! I have a problem with the RTC of 24FJ64GA306. It drops behind with a minute per hour. I have 32.768 kHz external clock with 2x33pf caps. I'm using MPlab v 8.93, CCS v4.134. I'm not sure if I have selected the external or the internal RTC clock.
Code: |
setup_rtc(RTC_ENABLE,0);
|
I tried to increase the adjust value 0 up to 9 - no effect!
Is this normal or I'm doing something wrong?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Sat Jan 04, 2014 12:51 pm |
|
|
The calibration, only applies if you are using the internal oscillator. With the external oscillator the value has no effect (which is what you are seeing). What is the loading required for your crystal (get it's data)?. 2*33pF sounds very high. Most 'watch' crystals require only something like 6pF, which is given by the tracks and the pin capacitance.....
Would explain it running slow.
Best Wishes |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Sat Jan 04, 2014 1:27 pm |
|
|
I wasn't sure about the caps! I supposed 33p is OK! I'll try to remove them! Usually the capacitance of a connection is 4pF so I suppose I'll have enough!
Do I always have to use external oscillator to achieve correct time or the internal can do the same?!
Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Sat Jan 04, 2014 1:35 pm |
|
|
This is where data is your friend.
With a correctly selected and loaded external crystal, you can easily get accuracies like a second a week or better.
With the internal RTC even if you tweak it to get it as good as possible, your one second per hour is about as good as you are likely to get for any time...
Key thing though is data.
Best Wishes |
|
|
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
|
Posted: Sun Jan 05, 2014 3:30 am |
|
|
Ok! I removed the 33pF caps, but now the RTC is running about 4 times slower!
I`m using this to set it:
Code: |
setup_rtc(RTC_ENABLE);
|
What did I mess-up again?! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Sun Jan 05, 2014 12:02 pm |
|
|
It's probably clocking on an overtone, because it is slightly overdriven.
Try adding a series resistor between the crystal and the drive pin.
As I say again _data_. You need the data sheet for your crystal, and what load it requires, as well as what drive level. |
|
|
|