Description
DS1307
DS1307 is the one of Real Time Clock IC i use. It just need I2C pin. The I2C is a simple, just two-wire connection can link multiple devices together and allow them to exchange data. There's one master device that communicates to multiple slave devices. They are connected in parallel to the two wires. Those wires are known SCL & SDA. SCL is clock line and is controlled by the master devices. SDA is transfer data.
This is the scematic picture :
All of electronic devices need source to work as it should. But, Time must go on whatever it take. so, DS1307 need 3V as external source. It's different with the main source of system.
Atmega16
For Atmel, I2C pins've to not PC0 and PC1. It can be selected pins whatever you want.
For example : If PC0 and PC1 are used not I2C. Then i choose PB0 & PB1 for I2C.
For example : If PC0 and PC1 are used not I2C. Then i choose PB0 & PB1 for I2C.
Here this code :
#asm
.equ __i2c_port=0x18 ;PORTB
.equ __sda_bit=0
.equ __scl_bit=1
#endasm
Codevision AVR has good interface. DS1307 header is available on it. Just read the header of DS1307 you can make a program like a BOSS. lol...
NOTE :
Anything else i miss? just tell me, then i'll kill you, lol... that's joke. don't you understand a joke?
NOTE :
Anything else i miss? just tell me, then i'll kill you, lol... that's joke. don't you understand a joke?
Requirements
- Atmega16
- DS1307
- 3V Battery
- 10K
- 32KHz Crystal
- Handsome (Success Increase)
Forget the last option. that's joke. if you want external clock for Atmega16 :
- 12MHz
- 22nF
- 22nF
Code Sample
void jam(){
rtc_get_time(&h,&m,&s);
rtc_get_date(&wk,&dd,&mm,&yy);
lcd_gotoxy(0,0);
sprintf(lcd,"%2u:%2u:%2u",h,m,s);
lcd_puts(lcd);
delay_ms(1000);
}
rtc_get_time(&h,&m,&s);
rtc_get_date(&wk,&dd,&mm,&yy);
lcd_gotoxy(0,0);
sprintf(lcd,"%2u:%2u:%2u",h,m,s);
lcd_puts(lcd);
delay_ms(1000);
}
Reference
Datasheet Atmega16 : http://www.atmel.com/Images/doc2466.pdf
Datasheet DS1307 : http://datasheets.maximintegrated.com/en/ds/DS1307.pdf


.equ __i2c_port=0x18 ;PORTB maksudnya apa kakak ?
ReplyDeleteitu sudah nilai equvalent untuk port B = 0x18, Port C = 15, Port B = 12, etc.
ReplyDeletemengapa bisa begitu kakak ? Mohon dijelaskan dong :)
ReplyDeleteDi datasheet ada. udah baca datasheet?
ReplyDeleteitu nilai equvalent untuk data register setiap port.
belum kak, datasheet atmel atau ds1307 ?
ReplyDeleteatmel
ReplyDeleteoh ya, makasih kak
ReplyDeleteshare lagi dong kak bagus dan bermanfaat nih :)