View previous topic :: View next topic |
Author |
Message |
micro_debugger
Joined: 08 Oct 2009 Posts: 73
|
How to switch PIC clock speed ? |
Posted: Mon Nov 18, 2013 12:49 pm |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Nov 18, 2013 6:11 pm |
|
|
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
|
|
Posted: Mon Nov 18, 2013 7:02 pm |
|
|
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: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Nov 18, 2013 7:32 pm |
|
|
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
|
|
Posted: Mon Nov 18, 2013 7:35 pm |
|
|
I will
Thank a lot !!!!!!!
Warmest Regards |
|
|
|