The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar.
This library set and get year, month, day, hour, minute and second from this RTC.
Setup parameters are stored in file ds1307.h
This library was developed on Eclipse, built with avr-gcc on Atmega8 @ 1MHz.
Code
Notes
- read risk disclaimer
- excuse my bad english
In DS1307.c is a line that says: * initialize the accellerometer :-)
ReplyDeletethank you for your feedback :)
Deleteyou have find a copy and paste comment error :-/
Hi,
ReplyDeletehow to use DS1307 with LCD16x2 library?
Hello. Just load the uint8_t outputs from the ds1307_getdate function to you LCD library. You should use the sprintf or the itoa function to build the output buffer to send to the LCD library.
Deletethis code works with ATmega328?
ReplyDeleteYes, it works.
Deletethis code works with ATmega16 ?
ReplyDeleteHello, I've never try it on an ATmega16, but it should work.
Deleteok, thank you
DeleteIt works for Atmega16 as well. Nice one Davide!
DeleteThank you for your feedback!
DeleteHi,
ReplyDeletethank you for the great library. Why do you calculate the dayofweek? I think the register 0x03 is for the dayofweek (0-7)?
Could you please explain, why you do this way, please?
Hello, i get the day of week to set the date. You can find the ds1307_getdayofweek call in the ds1307_setdate function.
DeleteHi,
Deletethank you for your answer, but I think it is a misunderstanding.
I am a newbe, and I do not know, if my opinion is wrong.
I think, the ds1307 calculates the day of week, because the datasheet says, that there is a register for it.
Your code reads only year, month, day, hour, minute and second from the ds1307 via I2C. And the function getdayofweek() calculates with y, m, d the day of week.
So why do you calculate the day of week in the microcontroller and do not use the ds1307 for it?
Greetings
I write that register during the setdate because I suppose it was incremented by the DS1307, but not computed. As datasheet states: "The day-of-week register increments at midnight. Values that correspond to the day of week are user-defined but must be sequential".
DeleteMy guess is that ds1307 does not know what is the initial value. But now you make me suspect that the 0x03 register is written by the DS1307. Can you test if is written by DS1307 or is just incremented by an initial value set by user? I'm actually fully involved in other project and can not test this. Thank you for your constructive comment.
This comment has been removed by the author.
ReplyDeleteHello, I want to ask why in my program there is an inscription Error: C: \ cvavreval \ inc \ ds1307.h (25), included from: jam.c: missing '('
ReplyDeletebisakan you please tell me?
I am sorry Indonesian people, so too could not english
Hello, it could be a file format setting.
Deletehow to fix that problem?
DeleteGrazie mille Davide
ReplyDeleteGrazie a te per il feedback ;)
Deleteplease send the code for interfacing GPS(NEO-6M-001) with
ReplyDeleteATMEGA328
Hello, you can find the code for this library above on this blog post. It should works on ATmega328, just update the uart library with the newer P.Fleury one.
DeleteThis comment has been removed by the author.
ReplyDeleteHello Davide,
ReplyDeleteThis is a really nice project!
How do you do to set the time through uart (I mean sending uint8_t via RealTerm)?
Actually, I would like to know how to get a string from uart instead of a single char.
Thanks.
Hello and thank you. The sample in this page does not implement an update time over UART protocol. You have to write your own protocol. I would use uart_getc and uart_gets. You can as example send a 0x55 character followed by 6 byte + 0x10 as ending, the 6 byte you send should be year, month, day, hour, minute, seconds. Reading that on your micro, parsing that out and setting time using ds1307_setdate function. Hope this helps.
Deletehow do you interface using 4x4 keypad as well as 16x2 lcd
ReplyDeleteHello, for the LCD library I suggest the P.Fleury one, for the keypad, you should build your own keypad matrix, I've a litte library for doing that, if needed i can post it.
Deleteesta biblioteca funciona en atmel studio?
ReplyDeleteHello, yes you can compile it with Atmel Studio too.
DeletePlease correct your library in file uart.c. Your missing in position 154.
ReplyDelete#elif defined(__AVR_ATmega168P__) || defined(__AVR_ATmega328P__)
/* ATmega with one USART */
#define ATMEGA_USART0
#define UART0_RECEIVE_INTERRUPT USART_RX_vect
#define UART0_TRANSMIT_INTERRUPT USART_UDRE_vect
#define UART0_STATUS UCSR0A
#define UART0_CONTROL UCSR0B
#define UART0_DATA UDR0
#define UART0_UDRIE UDRIE0
Hello, thank you for sharing your solution, an alternative is to update the P.Fluery uart library with the new one.
Deletei am not able to see the sch attached can you provide a photo instead
ReplyDeleteDear ano, you should also find the atmega8_ds1307_board_i2c_sample.png file that is the export image of the sch eagle schematic file.
Delete