Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

real time clock on pic MCU

Status
Not open for further replies.

nikens

Junior Member level 2
Joined
Dec 20, 2009
Messages
23
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
slovenia
Activity points
1,503
Is it possible to make RTC using PIC MCU with internal or external oscilator?
I have written a code for clock using timer TM0 and external 20MHz osiclator, but the clock is very inaccurate (-10 minutes per day).

So is it only way that I add external RTC IC like (PCF8583 or DS1307)?
 

Can you be a little more exact?

I really don't know what you tried to said.
 

it shud work fairly.. the inaccuracy, if any, shud be in order of seconds. can u post ur code or just tell how u configured the timer?
 

Hi Nikens,

If your clock is *consistently* lagging by 10 minutes per day, you are on the right track, just tweak the code. (Assuming you are using a crystal; if you are using the internal oscillator, just switching to a crystal might solve the problem)

To answer your question, to use a pic as an RTC, do not rely on the internal oscillator. Dont use a ceramic resonator either, go with a crystal.

I dont know what environment you are using, but here is something precisely similar to what you need, in PBP:

MEL PICBASIC Forum - Clock with use ofTimer1 and Interrupts

Hope it helps.

Regards,

Anand Dhuru
 

Hi,

If you work things out you will see 20meg does not readily divide down to 1 second.

A common way is to use a 32.678K xtal with Timer 1 to give the 1 second delay - typically accurate to a few seconds per week or use one of the add-on rtc chips

Alernativley have a look at this site Zero-error 1 second timing algorithm
 

use an 20mhz crystal oscillator or even 4mhz oscillator would do. prescale the timer to adjust the time encountered between adjacent incrementing of the timer and desing the value to be loaded into the timer so that when the timer rolls over to zero something like 50ms will be the time elapsed. on every rollover of the timer increment a variable from zero so that when that value equals the value 20 that means 1 second is done. continue with that logic. i successfully made a clock with pic16f877a using timer1 designed for 500ms delay
i hope it helps
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top