Page 1 of 2
PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Sat Jul 19, 2014 10:41 pm
by mayur.k.vadukul
Hi,
My RTCC module is using the LF-INTOSC of the PIC18F65K22. When the CPU is running, the RTCC is working correctly. i.e. the time calculation is accurate. However, when the PIC enters the SLEEP mode, it goes slow. The real time 1 sec = 2 second of the RTCC module.
For my application time accuracy is not significantly important and I am using RTCC only to wake up the CPU from sleep mode at various stages of my application.
To find out more, I have output the RTCC clock on the RTCC pin of the micro. I noticed when the CPU is running, it gives Appx 33KHz output but when it is in sleep mode it gives Appx 14KHz output, which explains why is it running slow.
Can anyone help me what settings determine the RTCC clock frequency in sleep mode?
Regards
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Sun Jul 20, 2014 2:21 pm
by Tom Maier
What value have you written to CONFIG3L <bit0>?
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Sun Jul 20, 2014 2:33 pm
by Tom Maier
Also, what do you have for REFOCON?
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Sun Jul 20, 2014 9:41 pm
by mayur.k.vadukul
CONFIG3L
Bit 0 = 0; RTCC uses LF INTOSC as reference clock
REF0CON
ROSEL = 1;
ROON = 0 ;
RODIV0 = 0 ;
RODIV1 = 0;
RODIV2 = 0;
RODIV3 = 0;
Regards
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Tue Jul 22, 2014 2:07 am
by Tom Maier
Check your REFOCON bits. You have selected external oscillator as source.
Also, ROSSLP bit needs to be set for sleep.
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Tue Jul 22, 2014 9:49 am
by mayur.k.vadukul
Thanks for the response.
I have tried ROSSLP = 1 but it did not make much difference. I have also tried to ROSEL = 0 and it did not work.
I assume since I sent Bit0 of CONFIG3L = 0, which is to use internal LF INTOSC as reference clock, REFOCON is insignificant. And since I am outputting the clock of the RTCC module to RTCC pin, I can monitor the clock of the RTCC module on the oscilloscope. When the CPU is running, it is 33-34KHz but when it is in sleep mode it is 14KHz. So there is the factor of 2 somewhere. I do not understand why my clock frequency from LF-INTOSC to RTCC is half in sleep mode?
Regards
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Tue Jul 22, 2014 12:45 pm
by Tom Maier
Can you post the code for all of your setup? Include fuse settings and init code for oscillator.
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Tue Jul 22, 2014 2:03 pm
by mayur.k.vadukul
Hi,
Please see the attached files.
I have created the project with all these files in MPLAB X with ICD3 and Hi-Tech Compiler.
Regards
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Wed Jul 23, 2014 1:02 pm
by Tom Maier
Well, I can't find the problem exactly, but I'm suspicious that during sleep mode the chip is changing over oscillators. It has two. That would explain the change in frequency.
Read over chapter 4 about the dual internal oscillator and switchover in sleep mode. It's pretty confusing. I wish they just had a chart of "what I want to achieve" vs. "how to set the registers".
Wish I could point it out for you exactly... it's a mind-bender to understand.
Re: PIC18F65K22 RTCC Slow in Sleep Mode

Posted:
Wed Jul 23, 2014 1:39 pm
by mayur.k.vadukul
I am baffled as well.
I am new to PIC but I have read the datasheet so many times and could not work out why it is slowing.
Another point being, it is LF-INTOSC which is used for RTCC and it does not have any prescaler or postscaler.
I can't get over the problem and is very annoying.
Thanks for your support.