![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
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? | |
| |
| | #2 |
|
I like to use real time clock calendar chips. When there is no system power they run off a battery. The often communicate by SPI or I2C. The one I use is the M41T00.
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) | |
| |
| | #3 |
|
I used DS1307 with backup battery support.
__________________ The Loosers Now Might Be Later To win For The Time's They're a Changing | |
| |
| | #4 |
| 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.
| |
| |
| | #5 | |
| Quote:
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 Loosers Now Might Be Later To win For The Time's They're a Changing | ||
| |
| | #6 | |
|
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. Quote:
__________________ Please post questions to the forums. PM's are for personal communication. BCHS/3v0's Tutorials Junebug USB PIC programmer kit., USB Bit Whacker, The 15 Minute Printed Circuit Board! (+drill time) | ||
| |
| | #7 |
|
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.
__________________ Mark Higgins | |
| |
| | #8 | |
| Quote:
| ||
| |
| | #9 | |
| Quote:
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 *
****************************************************************************
}
__________________ The Loosers Now Might Be Later To win For The Time's They're a Changing | ||
| |
| | #10 |
|
It worked. There is no need to initialize the control register. My problem was due to some mistake in the wiring.
| |
| |
|
| Tags |
| clock, real, time |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Real Time Clock Help for PICAXE 18x | johnjohn | Micro Controllers | 0 | 3rd December 2007 06:59 AM |
| Interfacing real time clock | goodpickles | General Electronics Chat | 1 | 13th February 2005 10:36 AM |
| Real Time Clock on LPT | l30 | Electronic Projects Design/Ideas/Reviews | 1 | 5th May 2004 07:50 AM |
| real time clock | finst | Micro Controllers | 4 | 17th January 2004 01:11 AM |
| list of Real Time Clock | thendo | Micro Controllers | 2 | 8th November 2003 06:41 PM |