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 switch PIC clock speed ?

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



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

How to switch PIC clock speed ?
PostPosted: Mon Nov 18, 2013 12:49 pm     Reply with quote

Re: Timer based Real Time Clock (RTC)
http://www.ccsinfo.com/forum/viewtopic.php?t=26177
I done it with the 16M crystal and working very well. My question is how do it with 32768 crystal which is connected to the T1, and in low power mode is also the system clock, in non low power the system clock is 16M. So the RTC should to be working all the time with 32768, independent if the system clock is 16M or 32K
Processor 18F25K20
CCS compile V5.015
Thank you in advance for help
Best Regards
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 18, 2013 6:11 pm     Reply with quote

For starters, you'ld have to 'setup' the timer1 function to use the external mode not the internal....

Be sure to calculate the correct caps for the xtal you've chosen. If you're off a couple of picofarads your timing will be off.

Please scan the Help files that CCS supplies (press F11 in an open project), look for setup_timer_x(), read what it says. There's probably an example in the examples folder as well...

hth
jay
micro_debugger



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

PostPosted: Mon Nov 18, 2013 7:02 pm     Reply with quote

Thank you for you reply

Quote:
For starters, you'ld have to 'setup' the timer1 function to use the external mode not the internal....

done

Quote:
Be sure to calculate the correct caps for the xtal you've chosen. If you're off a couple of picofarads your timing will be off.

What do you mean, i used 27pF, and all the time my clock is running bad losing couple of secs per day.

Quote:
Please scan the Help files that CCS supplies (press F11 in an open project), look for setup_timer_x(), read what it says. There's probably an example in the examples folder as well...

I done all that, and the system is running on the 32K, but i do not know how to set up the RTC for uP running on the 16M one time, and after that on the 32K and again.
Please help
Thank you in advance
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Nov 18, 2013 7:32 pm     Reply with quote

As you've found out 27 puff is too much. Try 22 and test. Maybe 15 pfd if still too slow. The real value depends upon component layout, xtal used, etc.

The RTC driver is very well 'self-documented'. Play 'computer', grab a pencil and paper and do the math for how the timer 'preload' value and timer 'ticks' were calculated. It was designed for a 16MHz 'clock' and you're using a 32K768 'clock', so you'll have to change the 'ticks per second' value for the ISR.

It's not that difficult to do and if you do it you'll have a better idea how and why the code works.

hth
jay
micro_debugger



Joined: 08 Oct 2009
Posts: 73

View user's profile Send private message

PostPosted: Mon Nov 18, 2013 7:35 pm     Reply with quote

I will

Thank a lot !!!!!!!
Warmest Regards
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