Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Real Time Clock

Status
Not open for further replies.

premkumar9

Member
Hi,
I am using 89S52 in a traffic controller. I need a real time clock also. I can do it with the same uC. But I need the clock to run even when there is a power failure. What is the best method suggested?
 
I used DS1307 with backup battery support.
I also used DS1307 in some cases. But I noticed difficulty in staring the counting . The same program which worked in one case doesn't start the oscillator (with DS1307) in another board. This type of problems take lot of my time. That is why I thought of adding the clock in the uC itself provided there is a method to make the clock work even during supply failure.
 
I also used DS1307 in some cases. But I noticed difficulty in staring the counting . The same program which worked in one case doesn't start the oscillator (with DS1307) in another board. This type of problems take lot of my time. That is why I thought of adding the clock in the uC itself provided there is a method to make the clock work even during supply failure.

I too noticed the same problem.
But I think,never tested,a good quality oscillator with ringed ground plane under the oscillator PCB pad can overcome the problem, it's just my thinking, I never tested.
I like the IC DS1307 pretty much, and I think a good quality PCB with ground plane is required for accurate and reliable timing.
 
The M41T00 datasheet has this about starting the clock. I do not know if it will work for others but there is no harm in trying. ST is the active low clock enable bit.

Note: In order to guarantee oscillator start-up after the initial power-up, set the ST bit to a '1,' then
reset this bit to a '0.' This sequence enables a “kick start” circuit which aids the oscillator start-up during worst case conditions of voltage and temperature.
 
DS1307 is a 5V supply only part, which makes it unusable to me. M41T00 takes 2.0V to 5.5V supply. That means I can use the M41T00 in all my projects, not just ones with 5V rails and don't need to write multiple libraries.

If you are going to pick a chip to use right now and you can carry on to later projects, you want something that you can use with 3.3V projects, as 5V is getting outdated with uC's.
 
I too noticed the same problem.
But I think,never tested,a good quality oscillator with ringed ground plane under the oscillator PCB pad can overcome the problem, it's just my thinking, I never tested.
I like the IC DS1307 pretty much, and I think a good quality PCB with ground plane is required for accurate and reliable timing.

Do you think that it is a must to initialize the control register?
 
Do you think that it is a must to initialize the control register?

really I made it very simple.
I used a user library from swordfish site.
It's very very simple to use Swordfish Wiki | SwordfishUser / DS1307 browse

I think they intialize all the control resistors.
Code:
dim 
   I2CWriteByte as WriteByte,
   I2CReadByte as ReadByte,
   I2CInitialize as Initialize,
   I2CStart as Start,
   I2CStop as Stop,
   I2CRestart as Restart
.......
{
****************************************************************************
* Name    : RTCStartWrite (PRIVATE)                                        *
* Purpose : Starts a RTC write                                             *
****************************************************************************
}
sub RTCStartWrite(Address as byte) 
   I2CStart
   I2CWriteByte(RTC_DEV_ADDR)
   I2CWriteByte(Address)        
end sub
{
****************************************************************************
* Name    : RTCStartRead (PRIVATE)                                         *
* Purpose : Starts a RTC read                                              *
****************************************************************************
}
sub RTCStartRead(Address as byte)
   RTCStartWrite(Address)
   I2CRestart
   I2CWriteByte(RTC_DEV_ADDR + 1)
end sub
{
****************************************************************************
* Name    : RTCStop (PRIVATE)                                              *
* Purpose : Stops RTC read or write                                        *
****************************************************************************
}
sub RTCStop()
   Acknowledge(I2C_NOT_ACKNOWLEDGE)
   Stop
end sub
{
****************************************************************************
* Name    : ReadRegister (PRIVATE)                                         *
* Purpose : Read DS1307 register ($00..$3F)                                *
****************************************************************************
}         
function ReadRegister(pAddress as byte) as byte
   RTCStartRead(pAddress)
   Result = I2CReadByte(I2C_NOT_ACKNOWLEDGE)
   RTCStop
end function
{
****************************************************************************
* Name    : WriteRegister (PRIVATE)                                        *
* Purpose : Write to DS1307 register ($00..$3F)                            *
****************************************************************************
}         
sub WriteRegister(pAddress as byte, pData as byte)
   RTCStartWrite(pAddress)
   I2CWriteByte(pData)
   RTCStop
end sub
{
****************************************************************************
* Name    : ReadControl                                                    *
* Purpose : Returns the RTC control byte ($07)                             *
*         : See the control constants RTC_SQWXXXX above                    *
****************************************************************************
}
 
It worked. There is no need to initialize the control register. My problem was due to some mistake in the wiring.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top