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.

RTC DS1307 Interfacing with MCU 89S52

Status
Not open for further replies.

H_D_R

Full Member level 6
Full Member level 6
Joined
Jan 31, 2008
Messages
329
Helped
26
Reputation
52
Reaction score
9
Trophy points
18
Location
India
Activity points
0
c code for interfacing ds1307 with 89s52

hello all..

i want to make the alarm using DS1307 and MCU 89S52.
and with the help of alarm i want to turn on/off the LEDs.


i have made routines for LCD 8-bit mode, 4X4 matrix Keyboard.

now what should i take next step for implementing clock and display it on LCD..??

can any one please help me..

All suggestions will be appriciated.

Thanks to you all in advance...

PS:: i am using Assembly Language language..
 

89c52 ds1307

i am able to understand the I2C routines for RTC but still i am confused for implementation of clock.

can any one help me please..

i have read some of threads regarding RTC but still not much clear...!!?

by the way what is watchdog timer.
can i use it in my application...???
 
  • Like
Reactions: draviblr

    V

    Points: 2
    Helpful Answer Positive Rating

    draviblr

    Points: 2
    Helpful Answer Positive Rating
89ss52 lcd clock

Because I don't understand ASM language, so I tell you about watchdog.
Watchdog timer is a timer that sends out a pulse every consecutive time. the delay can be preset or determined by user.
Microcontroller will or device that sent this pulse notifies another device that "I'm alive and ok!". Eg, a device receive a watchdog pulse from a microcontroller every 1s. When the device didn't receive it, it sends out reset signal to the microcontroller. In this way, the system will never hang.
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
ds1307 with 89s52

Ceko_Boy said:
Because I don't understand ASM language, so I tell you about watchdog.
Watchdog timer is a timer that sends out a pulse every consecutive time. the delay can be preset or determined by user.
Microcontroller will or device that sent this pulse notifies another device that "I'm alive and ok!". Eg, a device receive a watchdog pulse from a microcontroller every 1s. When the device didn't receive it, it sends out reset signal to the microcontroller. In this way, the system will never hang.

Thank you..

i am using asm means assembly language.

hope so any body else can help.
anyway thank u.
 

buffer ics to be used with 89s52

Hi,
A small correction regarding Watchdog Timer. It is a timer which has to be constantly triggered by the microcontroller at regular intervals to prevent it from producing an output pulse. If the controller fails to do it due its program losing control for some reason, the pulse output from the watchdog is used to reset the micro, thus ensuring that the micro recovers from its hanging state. It is a circuit that works like a watchdog on the proper working of the micro. You may or not, use it in your application.
Regards,
Laktronics
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
ds1307 interfacing c code

laktronics said:
Hi,
A small correction regarding Watchdog Timer. It is a timer which has to be constantly triggered by the microcontroller at regular intervals to prevent it from producing an output pulse. If the controller fails to do it due its program losing control for some reason, the pulse output from the watchdog is used to reset the micro, thus ensuring that the micro recovers from its hanging state. It is a circuit that works like a watchdog on the proper working of the micro. You may or not, use it in your application.
Regards,
Laktronics

hi laktronics,

thanks for clearing it bit deeply
can i use it in my application..??
if yes then please give me some detailed description...

Thank you.

noboady is ready to help..???
 

interfacing with mcu

i am using RTC DS1307 and EEPROM AT24C02 - both are sharing same I2C lines.

so how can i differentiate them in codeing and data transferring.??
 

89c52 reset circuit

Hi,
Ok, you can add a watchdog to your design. This can be done using a retriggerable monoshot which will be triggered using a port pin of S52. In your software, you have to ensure that you do this triggering regularly within a fixed interval say 10 millisec. In that case you design a monoshot with a pulse width >10msec, say 15 msec. Whenever the mono output goes to zero due to failure of CPU to trigger it, generate a reset pulse for your CPU.

You can also implement a watchdog with a counter counting a clock input. In this case, use the CPU port pin to reset the counter at regular intervals and should the counter count and overflow at any time, use the overflow output to reset the CPU.

And to H_D_R, use an external address other than '000', reserved for RTC for addressing 24C02.
Regards,
Laktronics
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
code for 89c52 mcu

laktronics said:
Hi,
Ok, you can add a watchdog to your design. This can be done using a retriggerable monoshot which will be triggered using a port pin of S52. In your software, you have to ensure that you do this triggering regularly within a fixed interval say 10 millisec. In that case you design a monoshot with a pulse width >10msec, say 15 msec. Whenever the mono output goes to zero due to failure of CPU to trigger it, generate a reset pulse for your CPU.

You can also implement a watchdog with a counter counting a clock input. In this case, use the CPU port pin to reset the counter at regular intervals and should the counter count and overflow at any time, use the overflow output to reset the CPU.

And to H_D_R, use an external address other than '000', reserved for RTC for addressing 24C02.
Regards,
Laktronics

thanks.

but it sounds quite complicated for me.
i think i have to read much more and more about watchdog.
if you dont mind please tell me something regarding my project now bcoz then and only then i can use it.

Thanks a gain for replying.
 

ds1307 mcu

Hi H_D_R

I don't think you need a watchdog to get the DS1307 working.

Check fig 4 & fig 5 on the bottom of page 12 of the DS1307 datasheet.
The first byte is the address of the DS1307 on the I²C bus.
When you want to read/write from/to the DS1307 you always need to send that byte first.

On the AT24C02 you have three pins A0 - A2 to setup a certain address. Connect these pins to Vcc/Gnd so that you have a different address than that from the DS1307.

Since the 4 higest bits are different in DS & AT, you can connect all three pins to GND.
That way you get:
address 1010 000x for the AT24C02
address 1101 000x for the DS1307

Clear? No ... ask
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
voice record mcu

hello,

Can any one please help me to understand this Paragraph. it is from RTC DS1307 Page no.8

"When reading or writing the time and date registers, secondary (user) buffers are used to prevent errors when the internal registers update. When reading the time and date registers, the user buffers are synchronized to the internal registers on any I2C START. The time information is read from these
secondary registers while the clock continues to run. This eliminates the need to re-read the registers in case the internal registers update during a read. The divider chain is reset whenever the seconds register is written. Write transfers occur on the I2C acknowledge from the DS1307. Once the divider chain is reset,
to avoid rollover issues, the remaining time and date registers must be written within one second."


please tell me what is the meaning of this bold words used here.
i am little bit confused about it.

Thanks
 

code c 89s52

Hi,
This only means that the time that you read from the RTC is the time at the start condition of I2C. This is ensured in the chip by having a set of user registers which will be updated from the actual time counting registers at the start condition.

Reading a register like the time counting register which changes asynchronously with read signal is otherwise always a probblem. See for example the case of the time register containing a vlue of 12:59:59. and you imagine soon after reading minutes and seconds, a seconds pulse has occurred at the input and the timer register changed to 1:00:00 value. Now if you read the hour register, you will get the total reading as 1:59:59 which is wrong. To avoid this condition,the chip ensures that you read only from the user buffer which will not be updated in the middle of a reading.
Similarly while setting the time, you start setting from seconds onwards, the clock divider chain ahead of 1 second pulse output gets reset so that you get one full second duration to load other time digits before the next update occurs. Here you are actually loading the running registers and not a buffer register.
Regards,
Laktronics
 
89c52 + watchdog

Looking at figure 1 the block diagram on page 4 you can see three blocks on the right side

upper block: 56 bytes of internal RAM address 08h to 3Fh
middle block: 8 control registers used by the DS address 00h to 07h
lower block: 7 so called "user buffer"

When you read from the DS, the data from the 8 control registers is copied into the user buffer and you read from that buffer. Copy starts with the START command on the I²C bus.

When you write to the DS, your data goes first to the user buffer, when all data is received it is copied into the 8 control registers.

Bottom line: don't worry about it, it's all internal stuff handled by the DS.
 

    H_D_R

    Points: 2
    Helpful Answer Positive Rating
interfacing of 16*4 lcd with 89c52

hello,

can any one please help me to clear this doubt.
Datahseet Ds1307 Page no:11

Data transfer from a slave transmitter to a master receiver. The first byte (the slave address) is transmitted by the master. The slave then returns an acknowledge bit. This is followed by the slave transmitting a number of data bytes. The master returns an acknowledge bit after all received bytes other than the last byte. At the end of the last received byte, a “not acknowledge” is returned.

here how the master will recoginze the last bit.please read the Bold line

sorry to divert from my main thread of project line
and asking question but this is also necessary to understand and easy implementation.

Thank you to all...!!

PS:: i have understood the reason for the bold line. please help me for next step.
thanks
Added after 38 minutes:

thanks mcs51mc,
i have got the idea of I2C in RTC more clearly but still some doubts.

by the way, i have got solution of my last question in this thread also.

but now, i have to implement.
so can anyone tell me from where i have to start.
i have made interfacing of 4 serial keys and LCD with my 89S52 successfully.
i have tested code on circuit also and working properly.
i have taken 4 switches for following purpose:
1- Up,
2- Down,
3- Set-time,
4-Set-Alarm.

now the only thing is left RTC DS1307.

is there anybody who can help..??

Thanking you all for reply and suggestions.
 

at24c02 program for interfacing with 8051

mcs51mc said:

Thanks for this link.

but i have visited already and it has code in C language programming.
and i am using ASM language...

any way, Thanks
 
watchdog timer overflow time for 89s52

I know it's C but with the free Keil C compiler you can compile it and get the ASM code from it :):):)
 

89s52 watchdog timer overflow

mcs51mc said:
I know it's C but with the free Keil C compiler you can compile it and get the ASM code from it :):):)


ya i can do in that way, but it will be quite difficult as i dont have command on C.
and Keil too..

can any body help..??!!! :(

thanks for trying your best to help me..:|
 

at24c02 reading problem

hello all,

can any one please tell me how can i store the time values in RTC...???

i have read I2C and datasheet of RTC also.

but still little bit confused..??

can any one please help...???
 

isd2560 16 keypad matrix

Hi,
I am sorry, I should have advised you this earlier, you should get everything about 8052 at www.8052.com. You should visit their code section, and I am sure your clock should me ticking over there, may be you have to join the forum to go to code section.
Regards,
Laktronics
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top