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.

DS1302 Problem with stopping the clock

Status
Not open for further replies.

shahsulax

Newbie level 4
Joined
Jan 1, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
1,320
DS1302 Problem

I have successfully interfaced DS1302 with 8051.

The application demands that at some of time I need to STOP the Clock, wait for 2 to 5 Seconds and then RESTART the CLOCK.

I am trying to do this using CH bit of DS1302. However am unsuccessful. Even though I am appropriately programming the CH bit = 1 in Seconds Register to STOP the clock and then setting this CH bit = 0 to RESTART the clock - the clock doesn't RESTART.

The CLOCK only starts if i Switch off the System and Switch it back ON.

Why this is happening ? Is there something specific that I need to take care to STOP, WAIT and START the clock again !

If anyone can help !
 

Re: DS1302 Problem

Try the following and see how it goes ..



Starting the Clock and resetting values (first time run):

Write %10000000 to address 80h ... This stops the clock

Write %00000000 to address 84h ... This initializes the clock in 24 hour mode and clears the hours to "00"

Write %00000000 to address 82h ... This clears the minutes to "00"

Write %00000000 to address 80h ... This starts the clock and clears the minutes to "00"


Stop the Clock and read elapsed time:

Read from address 81h and store in 'seconds'

subtract 128 from 'seconds' and Write the new value of 'seconds' to address 80h ... This stops the clock and preserves the seconds value

Read from address 82h and store in 'minutes'

Read from address 84h and store in 'hours'


Restart the Clock resume counting elapsed time:

add 128 to 'seconds' and Write new 'seconds' value to address 80h ... This starts the clock and preserves the seconds value

Rgds,
IanP
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top