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

RTC using 18F4550

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








RTC using 18F4550
PostPosted: Wed Oct 21, 2009 11:16 am     Reply with quote

Hello all,

I'm considering rolling my own RTC function using the "secondary" (TIMER 0) oscillator that is built into the 18F4550. According the the datasheet, this oscillator is often used with a 32.768 kHz watch crystal. Seems like a "nearly free" way to implement an RTC without using a dedicated clock chip (DS1307, DS1340, etc). I only need to have a fairly accurate clock/calender with the most basic functions. The challenge might be in the life of the backup battery as the PIC draws somewhere between about 2 and 35 uA while running off the 32 kHz oscillator. This is much higher than that required by a DS1307 for example.

Any thoughts or experiences are greatly appreciated.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 12:23 pm     Reply with quote

Consider using the 18FxxJ11 series that have built in RTC's and can do your time keeping function for you with that same 32kHz source.

I'd have to check, but I think the powerdown current is lower too because in the case of the J11's the CPU can shut down while the clock keeps running whereas the 18F4450 cannot.


Just a thought.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 12:47 pm     Reply with quote

Quote:

I'm considering rolling my own RTC function using the "secondary"
(TIMER 0) oscillator that is built into the 18F4550. According the the
datasheet, this oscillator is often used with a 32.768 kHz watch crystal.

Actually it's Timer1 that can do this.

To find threads on this topic, use the forum's search engine to search for
these keywords, and set it to search for all terms:
Quote:

rtc #int_timer1

x Search for all terms

http://www.ccsinfo.com/forum/search.php
Guest








PostPosted: Wed Oct 21, 2009 1:04 pm     Reply with quote

Thanks PCM. You're correct - it is Timer 1, not Timer 0. I'm familiar with the basics of an RTC implementation, however have not had any experience with trying to get a PIC (that has the secondary oscillator capability) to run at a low enough current to come close to rivaling a "real" stand-alone RTC chip. In order to do this, the PIC would have to be able to run 24/7 - even during a power loss. My application is not battery-powered which is a plus. I think the question comes down to being able to power the PIC from a coin cell when my board gets powered-down or loses power.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 21, 2009 2:05 pm     Reply with quote

If you're looking for battery backup circuits, this Tips 'n Tricks document
from Microchip shows the typical Schottky diode circuit:
http://ww1.microchip.com/downloads/en/DeviceDoc/01146B_chapter%202.pdf

Or, more suggestions:
http://www.microchip.com/forums/tm.aspx?m=398317
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

Re: RTC using 18F4550
PostPosted: Thu Oct 22, 2009 3:07 am     Reply with quote

Anonymous wrote:
... the PIC draws somewhere between about 2 and 35 uA while running off the 32 kHz oscillator. This is much higher than that required by a DS1307 for example.
The Maxim datasheet for the DS1307 mentions 200uA standby current. Seems like the PIC is not so bad at all...
Only thing from other threads in this forum is that I understand it is not so easy to actually get the PIC down to a few uA. Things like poor board layout, open input pins, programming mistakes, inefficient power supply, etc. cause the PIC to consume much higher currents. In my low volume designs we considered the costs for getting the software to run correctly much higher than the price for an additional hardware RTC.

In case you consider adding a hardware RTC than have a look at NXP, Seiko and TI for newer RTC designs at lower costs with less power consumption. Some of these chips have the crystal embedded in the same housing for a lower price than the crystal costs when you buy it seperate.
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Oct 22, 2009 10:50 am     Reply with quote

Interesting.

The PIC18FxxJ11 (I was looking) shows a spec of 850nA for running the RTC and another 1uA for timer1's oscillator (needed for running the clock - if I'm reading that right)

That's not bad at all.

And yes, software can make a lot of boo-boo's that up that consumption.

but at least they don't need cut-patch repairs to a PCB. :D

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 22, 2009 11:37 am     Reply with quote

Actually it says the ds1307 battery backup current is 300 na typical:
Code:

VBAT Current (OSC ON);    300 typ   500 max    na
SQW/OUT OFF

Look at the table on the bottom of page 2 in the data sheet:
http://datasheets.maxim-ic.com/en/ds/DS1307.pdf
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 22, 2009 1:12 pm     Reply with quote

While 500 nA of DS1307 is a max value over the full temperature range, you have to consider worst case values of about 5 uA with "nanoWatt XLP" PIC18FxxJ11. DS1307 easily achieves 5 or 10 years operation with the smallest available coin cell, I'm not aware yet of any processor that can compete in this regard.

As an additional point, a separate RTC allows easy specific battery backup, much more auxilary circuitry is involved with battery supply of the processor. A suitable integrated RTC hardware would preferably provide a dedicated Vbat pin.
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