CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

How to adjust the RTC of 24FJ64GA306

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

How to adjust the RTC of 24FJ64GA306
PostPosted: Sat Jan 04, 2014 11:53 am     Reply with quote

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: 19477

View user's profile Send private message

PostPosted: Sat Jan 04, 2014 12:51 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 04, 2014 1:27 pm     Reply with quote

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: 19477

View user's profile Send private message

PostPosted: Sat Jan 04, 2014 1:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jan 05, 2014 3:30 am     Reply with quote

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: 19477

View user's profile Send private message

PostPosted: Sun Jan 05, 2014 12:02 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group