PDA

View Full Version : Overclock RTC?



jimbostlawrence
- 20th December 2013, 10:52
Hi all,

I have some circuits that are professionally made using an 18F26J53. I cannot remove the 32 KHz clock that is at the timer1 input pins. The chip's primary oscillator is a 16 MHz crystal. I was wondering if it is possible to 'overclock' the RTC? I want to test some code to see if the unit behaves itself over a period of months (it has various tasks to do every day and at the end of a period of weeks/months) and I'd prefer to not have to wait months to test the routine only to find it fails on the last day!

Essentially, is there a way to 'up the pulse rate' from the internal oscillator that the RTC unit sees so that an hour can be compressed for instance into 1 second or something relatively rapid?

I've had a nose through the datasheet (RTC section and the Oscillator config section mainly) but can't be sure if this is possible, as it's not something that would normally be done. If it comes to it, I could sacrifice a semi-'duff' board and connect up another crystal in place of the 32 KHz but thought that would be messy - by software is the preferred method...

Any hints/tips on this issue would be gratefully received.

Best wishes for Christmas and the New Year to all out there!

Jimbo Stlawrence

Cheers

Mark

HenrikOlsson
- 20th December 2013, 11:50
Hi,
As far as I can see the RTC can be clocked either by the TMR1 Oscillator using a 32.768kHz crystal OR from the internal low power RC-oscillator. I don't think there's a way to drive the RTC module from the "normal" internal oscillator because then the RTC would shut down when the PIC enters low power mode since the oscillator is shut down. And, in the datasheet, below table 31-16 it says: The Timer1 oscillator is designed to drive 32.768 kHz crystals. When T1CKI is used as a digital input, frequencies up to 12 MHz are supported. So I don't think reworking a board to replace the 32kHz crsytal with something else is going to work either....

The only thing *I* can currently come up with is the include some test-code in the firmware that basically advances the clock by 59 min 58 seconds after each "1-hour task" and so on. Obviously, doing so may introduce OTHER bugs but what you're going to do?

/Henrik.

jimbostlawrence
- 21st December 2013, 00:18
Hi Henrik,

Thanks for having a think. I have already used code to jump the clock to critical time points (just before a sleep routine/wake-up routine), but it's never a true substitute for actually "running the clock/system the way it has to be run in the code". I have had a suggestion to try a remote control 455 kHz resonator; will see what I can come up with. Maybe sacrifice a slightly duff board for the cause to test the sleep routines. Didn't want to have to solder/savage a board but if that is what needs to be done I'll give it a shot.

Kind regards

Jimbo

Amoque
- 24th December 2013, 13:55
I should think that the hardware, "messy", means would be preferred (I mean except for the effort and expense). In this way you can run and develop software that will be, line for line, transferable to the accurately timed board - any artifacts between software versions are eliminated. Indeed, I can think of no better way to verify the operation of the "final" version of software than running it unmodified on high-speed hardware.


Just a thought...

Amoque

Merry Christmas, all!

HenrikOlsson
- 25th December 2013, 08:22
Hi,
I agree, doing it in hardware would be preffered it's just that (if I'm not mistaken of course) the hardware doesn't support doing that.
The TMR1 oscillator is designed to operate at 32.768kHz, overcklocking it to some faster frequency is operating it outside its specification. If a problem pops up is it due to the code or to the oscillator being run outside its spec?

On the other hand, if it does work then at least you should have no problems running it at the correct frequency. Only one way to find out, try it and tell us how it went!

/Henrik.

Darrel Taylor
- 25th December 2013, 17:31
The Timer1 oscillator may only work with 32.768kHz, but T1CKI can take up to 12Mhz (according to post #2) :)

Remove the crystal, and use another PIC to inject whatever frequency you want.

jimbostlawrence
- 27th December 2013, 00:32
Many thanks all. I'll give it a shot when I return to work and see how I get on with this.

Will let you know my findings. I know how important it is to post any resolutions on forums...

Kind regards and merry Christmas to all!

-Jimbo-