<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Interfacing DS1307 RTC Chip with AVR Microcontroller</title>
	<atom:link href="http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/feed/" rel="self" type="application/rss+xml" />
	<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/</link>
	<description></description>
	<lastBuildDate>Wed, 08 Feb 2012 03:41:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-37977</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Mon, 23 Jan 2012 19:24:09 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-37977</guid>
		<description>Hi Avinash!
2 questions:
1- Can I use different ports for display data port? Lets say I need lcd D4-D6 on pins C4 - C6 and lcd pin D7 on B2, or data pins must be on same port?
2. I use atmega32a for rtc. every time I power on device lcd shows uninitialized (showing only first row), but after reset it&#039;s okay(time &amp; date normally displayed)! Have some idea?

Regards,
Filip</description>
		<content:encoded><![CDATA[<p>Hi Avinash!<br />
2 questions:<br />
1- Can I use different ports for display data port? Lets say I need lcd D4-D6 on pins C4 &#8211; C6 and lcd pin D7 on B2, or data pins must be on same port?<br />
2. I use atmega32a for rtc. every time I power on device lcd shows uninitialized (showing only first row), but after reset it&#8217;s okay(time &amp; date normally displayed)! Have some idea?</p>
<p>Regards,<br />
Filip</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Povilas</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-37916</link>
		<dc:creator>Povilas</dc:creator>
		<pubDate>Thu, 19 Jan 2012 11:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-37916</guid>
		<description>I have little problem. When I connect it on proteus on LCD my time is 00:00:00 and it dosnt calculate. When I set time ex. 09:32:12 Am and out on main sreen it also 00:00:00. Any ideas? :)</description>
		<content:encoded><![CDATA[<p>I have little problem. When I connect it on proteus on LCD my time is 00:00:00 and it dosnt calculate. When I set time ex. 09:32:12 Am and out on main sreen it also 00:00:00. Any ideas? <img src='http://extremeelectronics.co.in/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DS1307 Based RTC Module &#124; eXtreme Electronics</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-36917</link>
		<dc:creator>DS1307 Based RTC Module &#124; eXtreme Electronics</dc:creator>
		<pubDate>Thu, 29 Dec 2011 08:28:41 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-36917</guid>
		<description>[...] such RTC IC is DS1307. It communicates with the host using I2C serial interface. We have put all the required components in one PCB to make a neat module that we can hook up to [...]</description>
		<content:encoded><![CDATA[<p>[...] such RTC IC is DS1307. It communicates with the host using I2C serial interface. We have put all the required components in one PCB to make a neat module that we can hook up to [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-35877</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Mon, 19 Dec 2011 07:56:17 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-35877</guid>
		<description>few sereenshots of modification you can find at:

http://ucdesignplay.blogspot.com/2011/12/ds1307-rtc-with-hd44780-lcd.html

filip</description>
		<content:encoded><![CDATA[<p>few sereenshots of modification you can find at:</p>
<p><a href="http://ucdesignplay.blogspot.com/2011/12/ds1307-rtc-with-hd44780-lcd.html" rel="nofollow">http://ucdesignplay.blogspot.com/2011/12/ds1307-rtc-with-hd44780-lcd.html</a></p>
<p>filip</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-35828</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Sun, 18 Dec 2011 17:53:12 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-35828</guid>
		<description>yes, no problem. I just altered your rtc.c file. First line of display shows time and second date, month , year and day in a week. Days in week are named in Croatian ;) , so this need to be cahnged. 
On menu I added &quot;set date&quot; where you can set all these parameters. 
It works fine, I plan to add temp and humidity and make little weather station.
Here&#039;s the code.
RTC.c:

#include 
#include 

#include &quot;I2C.h&quot;
#include &quot;lcd.h&quot;
#include &quot;ds1307.h&quot;

void ShowMainMenu();
void SetTime();

void Wait()
{
	uint8_t i;
	for(i=0;i&lt;20;i++)
		_delay_loop_2(0);
}

uint8_t PREV_PINB=0xFF;
/*

Function to test the current status of keys(0 to 2)

returns
0 if NOT pressed
1 if Pressed

*/
uint8_t GetKeyStatus(uint8_t key)
{
	return (!(PINB &amp; (1&lt;&lt;key)));
}

/*

Function to test the previous status of keys(0 to 2)

returns
0 if NOT pressed
1 if Pressed

*/
uint8_t GetPrevKeyStatus(uint8_t key)
{
	return (!(PREV_PINB &amp; (1&lt;&lt;key)));
}
void main()
{
	//Wait Util Other device startup
	_delay_loop_2(0);
	_delay_loop_2(0);

	//Initialize the LCD Module
	LCDInit(LS_BLINK);

	//Initialize I2C Bus
	I2CInit();

	//Enable Pull ups on keys
	PORTB&#124;=((1&lt;&lt;PB2)&#124;(1&lt;&lt;PB1)&#124;(1&lt;&lt;PB0));

	//Clear CH bit of RTC
	#define CH 7

	uint8_t temp;
	DS1307Read(0x00,&amp;temp);

	//Clear CH Bit - Clock Halt bit=0
	temp&amp;=(~(1&lt;&gt;4);
		Time[5]=&#039;:&#039;;
	
		DS1307Read(0x01,&amp;data);//minute
	
		Time[4]=48+(data &amp; 0b00001111);
		Time[3]=48+((data &amp; 0b01110000)&gt;&gt;4);
		Time[2]=&#039;:&#039;;
	
		DS1307Read(0x02,&amp;data);//sati
	
		Time[1]=48+(data &amp; 0b00001111);
		Time[0]=48+((data &amp; 0b00110000)&gt;&gt;4);

		
		LCDWriteStringXY(0,0,Time);

		DS1307Read(0x06,&amp;data);	 //godina
		Date[8]=&#039;&#039;;
		Date[7]=48+(data &amp; 0b00001111);
		Date[6]=48+((data &amp; 0b11110000)&gt;&gt;4);
		Date[5]=&#039;/&#039;;
	
		DS1307Read(0x05,&amp;data); //mjesec
	
		Date[4]=48+(data &amp; 0b00001111);
		Date[3]=48+((data &amp; 0b00010000)&gt;&gt;4);
		Date[2]=&#039;/&#039;;
	
		DS1307Read(0x04,&amp;data); //dan u mjesecu
	
		Date[1]=48+(data &amp; 0b00001111);
		Date[0]=48+((data &amp; 0b00110000)&gt;&gt;4);

		LCDWriteStringXY(0,1,Date);

		DS1307Read(0x03,&amp;data); //dan u tjednu
		
		Dan=data &amp; 0b00000111;
		
		switch (Dan)
		{
        case 1 : LCDWriteStringXY(9,1,&quot;Pon&quot;); break;
        case 2 : LCDWriteStringXY(9,1,&quot;Uto&quot;); break;
        case 3 : LCDWriteStringXY(9,1,&quot;Sri&quot;); break;
        case 4 : LCDWriteStringXY(9,1,&quot;Cet&quot;); break;
        case 5 : LCDWriteStringXY(9,1,&quot;Pet&quot;); break;
        case 6 : LCDWriteStringXY(9,1,&quot;Sub&quot;); break;
        case 7 : LCDWriteStringXY(9,1,&quot;Ned&quot;); break;
        }
		
		/*//AM/PM
		if(data &amp; 0b00100000)
		{
		LCDWriteStringXY(0,1,&quot;Poslije podne&quot;);
		}
		else
		{
		LCDWriteStringXY(0,1,&quot;Prije podne  &quot;);
		}
*/
		//Wait Some time and keep testing key input
		uint8_t i;
		for(i=0;i&lt;20;i++)
		{
		
			if(GetKeyStatus(2))
			{
				//Go To Main Menu
				ShowMainMenu();

				_delay_loop_2(0);
				_delay_loop_2(0);
				_delay_loop_2(0);

			}
			_delay_loop_2(5000);
		}
	}
	

	
}

void ShowMainMenu()
{
	//The Main Menu
	char *menu_items[]={ 	&quot;Set Time&quot;,
							&quot;Set Date&quot;,
							&quot;Quit&quot;
						};
	uint8_t menu_count=3;
	uint8_t selected=0;

	_delay_loop_2(0);
	_delay_loop_2(0);

	while(1)
	{
		LCDClear();
		LCDWriteString(&quot;    Main Menu  &quot;);

		LCDWriteStringXY(2,1,menu_items[selected]);

		LCDWriteStringXY(0,1,&quot;&quot;);

		if(GetKeyStatus(1))
		{
			//Left Key(No 1) is pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(1))
			{
				if(selected !=0)
					selected--;
			}
		}

		if(GetKeyStatus(0))
		{
			//Right Key(No 0) is pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(0))
			{
				if(selected !=(menu_count-1))
					selected++;
			}
		}

		if(GetKeyStatus(2))
		{
			//Enter Key Pressed
			//Check that it was not pressed previously
			if(!GetPrevKeyStatus(2))
			{
				//Call Appropriate Function
				switch (selected)
				{
					case 0:
						SetTime();
						break;
					case 1:
						SetDate();
						break;

					case 2:
						return;//Quit
						

					//case 3:
					//	return;//Quit
				}
				
			}
		}

		PREV_PINB=PINB;

		_delay_loop_2(5000);
	}
}

void SetTime()
{
	

	uint8_t hr,min,sec,temp;

	//Read the Second Register
	DS1307Read(0x00,&amp;temp);
	sec=(((temp &amp; 0b01110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);

	//Read the Minute Register
	DS1307Read(0x01,&amp;temp);
	min=(((temp &amp; 0b01110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);

	//Read the Hour Register
	DS1307Read(0x02,&amp;temp);
	hr=(((temp &amp; 0b00110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);

	uint8_t sel=0;

	while(1)
	{
		LCDClear();

		LCDWriteString(&quot;00:00:00    &quot;);
		
		LCDWriteIntXY(0,0,hr,2);
		LCDWriteIntXY(3,0,min,2);
		LCDWriteIntXY(6,0,sec,2);

		
		//Draw Pointer
		LCDWriteStringXY(sel*3,1,&quot;^^&quot;);

		//Input Up key
		if(GetKeyStatus(1))
		{
			if(!GetPrevKeyStatus(1))
			{
				if(sel==0)
				{	
					//Hour
					if(hr==24)
					{
						hr=0;
					}
					else
					{
						hr++;
					}
				}

				if(sel==1)
				{	
					//Min
					if(min==59)
					{
						min=0;
					}
					else
					{
						min++;
					}
				}

				if(sel==2)
				{	
					//Sec
					if(sec==59)
					{
						sec=0;
					}
					else
					{
						sec++;
					}
				}

				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		//Input Down
		if(GetKeyStatus(0))
		{
			if(!GetPrevKeyStatus(0))
			{
				if(sel==0)
				{	
					//Hour
					if(hr==0)
					{
						hr=23;
					}
					else
					{
						hr--;
					}
				}

				if(sel==1)
				{	
					//Min
					if(min==0)
					{
						min=59;
					}
					else
					{
						min--;
					}
				}

				if(sel==2)
				{	
					//Sec
					if(sec==0)
					{
						sec=59;
					}
					else
					{
						sec--;
					}
				}

				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		if(GetKeyStatus(2))
		{
			if(!GetPrevKeyStatus(2))
			{
				//Change Selection
				if(sel==4)
					sel=0;
				else
					sel++;
			}
		}

		PREV_PINB=PINB;

		_delay_loop_2(30000);

	}

	//Now write time back to RTC Module
	temp=((sec/10)&lt;&lt;4)&#124;(sec%10);
	DS1307Write(0x00,temp);

	temp=((min/10)&lt;&lt;4)&#124;(min%10);
	DS1307Write(0x01,temp);

	temp=((hr/10)&lt;&lt;4)&#124;(hr%10);
	temp&amp;= ~(0b01000000); // 24 satno vrijeme
	
	DS1307Write(0x02,temp);

	LCDClear();
	LCDWriteString(&quot;Time Set !&quot;);
	
	uint8_t i;
	for(i=0;i&gt;4)*10)+(temp &amp; 0b00001111);

	//Read the Month Register
	DS1307Read(0x05,&amp;temp);
	month=(((temp &amp; 0b00010000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);

	//Read the Year Register
	DS1307Read(0x06,&amp;temp);
	yr=(((temp &amp; 0b11110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);

	//Procitaj registar za Dan
	DS1307Read(0x03,&amp;temp);
	dan=temp &amp; 0b00000111;

	uint8_t sel=0;

	while(1)
	{
		LCDClear();

		LCDWriteString(&quot;00/00 0  00 &quot;);
		
		LCDWriteIntXY(0,0,date,2);
		LCDWriteIntXY(3,0,month,2);
		LCDWriteIntXY(6,0,dan,2);
		LCDWriteIntXY(9,0,yr,2);

		//Draw Pointer
		LCDWriteStringXY(sel*3,1,&quot;^^&quot;);

		//Input Up key
		if(GetKeyStatus(1))
		{
			if(!GetPrevKeyStatus(1))
			{
				if(sel==0)
				{	
					//Date
					if(date==32)
					{
						date=1;
					}
					else
					{
						date++;
					}
				}

				if(sel==1)
				{	
					//Month
					if(month==13)
					{
						month=1;
					}
					else
					{
						month++;
					}
				}

				if(sel==2)
				{	
					//Dan
					if(dan==8)
					{
						dan=1;
					}
					else
					{
						dan++;
					}
				}

				if(sel==3)
				{	
					//Year
					if(yr==99)
					{
						yr=1;
					}
					else
					{
						yr++;
					}
				}
				
				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		//Input Down
		if(GetKeyStatus(0))
		{
			if(!GetPrevKeyStatus(0))
			{
				if(sel==0)
				{	
					//Date
					if(date==0)
					{
						date=31;
					}
					else
					{
						date--;
					}
				}

				if(sel==1)
				{	
					//Month
					if(month==0)
					{
						month=12;
					}
					else
					{
						month--;
					}
				}
				
				if(sel==2)
				{	
					//Dan
					if(dan==0)
					{
						dan=7;
					}
					else
					{
						dan--;
					}
				}
				
				if(sel==3)
				{	
					//Year
					if(yr==0)
					{
						yr=99;
					}
					else
					{
						yr--;
					}
				}

				if(sel == 4)
				{
					//OK
					break;
				}
			}
		}

		if(GetKeyStatus(2))
		{
			if(!GetPrevKeyStatus(2))
			{
				//Change Selection
				if(sel==4)
					sel=0;
				else
					sel++;
			}
		}

		PREV_PINB=PINB;

		_delay_loop_2(30000);

	}

	//Now write DATE back to RTC Module
	temp=((date/10)&lt;&lt;4)&#124;(date%10);
	DS1307Write(0x04,temp);

	temp=((month/10)&lt;&lt;4)&#124;(month%10);
	DS1307Write(0x05,temp);

	temp=((yr/10)&lt;&lt;4)&#124;(yr%10);
	DS1307Write(0x06,temp);
	
	temp=dan%10;
	DS1307Write(0x03,temp);

	LCDClear();
	LCDWriteString(&quot;Date Set !&quot;);
	
	uint8_t i;
	for(i=0;i&lt;10;i++)
		_delay_loop_2(0);




}

I changed pm/am to 24 hout time and added 1Hz signal output of ds1307.

Regards
Filip</description>
		<content:encoded><![CDATA[<p>yes, no problem. I just altered your rtc.c file. First line of display shows time and second date, month , year and day in a week. Days in week are named in Croatian <img src='http://extremeelectronics.co.in/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  , so this need to be cahnged.<br />
On menu I added &#8220;set date&#8221; where you can set all these parameters.<br />
It works fine, I plan to add temp and humidity and make little weather station.<br />
Here&#8217;s the code.<br />
RTC.c:</p>
<p>#include<br />
#include </p>
<p>#include &#8220;I2C.h&#8221;<br />
#include &#8220;lcd.h&#8221;<br />
#include &#8220;ds1307.h&#8221;</p>
<p>void ShowMainMenu();<br />
void SetTime();</p>
<p>void Wait()<br />
{<br />
	uint8_t i;<br />
	for(i=0;i&lt;20;i++)<br />
		_delay_loop_2(0);<br />
}</p>
<p>uint8_t PREV_PINB=0xFF;<br />
/*</p>
<p>Function to test the current status of keys(0 to 2)</p>
<p>returns<br />
0 if NOT pressed<br />
1 if Pressed</p>
<p>*/<br />
uint8_t GetKeyStatus(uint8_t key)<br />
{<br />
	return (!(PINB &amp; (1&lt;&lt;key)));<br />
}</p>
<p>/*</p>
<p>Function to test the previous status of keys(0 to 2)</p>
<p>returns<br />
0 if NOT pressed<br />
1 if Pressed</p>
<p>*/<br />
uint8_t GetPrevKeyStatus(uint8_t key)<br />
{<br />
	return (!(PREV_PINB &amp; (1&lt;&lt;key)));<br />
}<br />
void main()<br />
{<br />
	//Wait Util Other device startup<br />
	_delay_loop_2(0);<br />
	_delay_loop_2(0);</p>
<p>	//Initialize the LCD Module<br />
	LCDInit(LS_BLINK);</p>
<p>	//Initialize I2C Bus<br />
	I2CInit();</p>
<p>	//Enable Pull ups on keys<br />
	PORTB|=((1&lt;&lt;PB2)|(1&lt;&lt;PB1)|(1&lt;&lt;PB0));</p>
<p>	//Clear CH bit of RTC<br />
	#define CH 7</p>
<p>	uint8_t temp;<br />
	DS1307Read(0&#215;00,&amp;temp);</p>
<p>	//Clear CH Bit &#8211; Clock Halt bit=0<br />
	temp&amp;=(~(1&lt;&gt;4);<br />
		Time[5]=&#8217;:';</p>
<p>		DS1307Read(0&#215;01,&amp;data);//minute</p>
<p>		Time[4]=48+(data &amp; 0b00001111);<br />
		Time[3]=48+((data &amp; 0b01110000)&gt;&gt;4);<br />
		Time[2]=&#8217;:';</p>
<p>		DS1307Read(0&#215;02,&amp;data);//sati</p>
<p>		Time[1]=48+(data &amp; 0b00001111);<br />
		Time[0]=48+((data &amp; 0b00110000)&gt;&gt;4);</p>
<p>		LCDWriteStringXY(0,0,Time);</p>
<p>		DS1307Read(0&#215;06,&amp;data);	 //godina<br />
		Date[8]=&#8221;;<br />
		Date[7]=48+(data &amp; 0b00001111);<br />
		Date[6]=48+((data &amp; 0b11110000)&gt;&gt;4);<br />
		Date[5]=&#8217;/';</p>
<p>		DS1307Read(0&#215;05,&amp;data); //mjesec</p>
<p>		Date[4]=48+(data &amp; 0b00001111);<br />
		Date[3]=48+((data &amp; 0b00010000)&gt;&gt;4);<br />
		Date[2]=&#8217;/';</p>
<p>		DS1307Read(0&#215;04,&amp;data); //dan u mjesecu</p>
<p>		Date[1]=48+(data &amp; 0b00001111);<br />
		Date[0]=48+((data &amp; 0b00110000)&gt;&gt;4);</p>
<p>		LCDWriteStringXY(0,1,Date);</p>
<p>		DS1307Read(0&#215;03,&amp;data); //dan u tjednu</p>
<p>		Dan=data &amp; 0b00000111;</p>
<p>		switch (Dan)<br />
		{<br />
        case 1 : LCDWriteStringXY(9,1,&#8221;Pon&#8221;); break;<br />
        case 2 : LCDWriteStringXY(9,1,&#8221;Uto&#8221;); break;<br />
        case 3 : LCDWriteStringXY(9,1,&#8221;Sri&#8221;); break;<br />
        case 4 : LCDWriteStringXY(9,1,&#8221;Cet&#8221;); break;<br />
        case 5 : LCDWriteStringXY(9,1,&#8221;Pet&#8221;); break;<br />
        case 6 : LCDWriteStringXY(9,1,&#8221;Sub&#8221;); break;<br />
        case 7 : LCDWriteStringXY(9,1,&#8221;Ned&#8221;); break;<br />
        }</p>
<p>		/*//AM/PM<br />
		if(data &amp; 0b00100000)<br />
		{<br />
		LCDWriteStringXY(0,1,&#8221;Poslije podne&#8221;);<br />
		}<br />
		else<br />
		{<br />
		LCDWriteStringXY(0,1,&#8221;Prije podne  &#8220;);<br />
		}<br />
*/<br />
		//Wait Some time and keep testing key input<br />
		uint8_t i;<br />
		for(i=0;i&lt;20;i++)<br />
		{</p>
<p>			if(GetKeyStatus(2))<br />
			{<br />
				//Go To Main Menu<br />
				ShowMainMenu();</p>
<p>				_delay_loop_2(0);<br />
				_delay_loop_2(0);<br />
				_delay_loop_2(0);</p>
<p>			}<br />
			_delay_loop_2(5000);<br />
		}<br />
	}</p>
<p>}</p>
<p>void ShowMainMenu()<br />
{<br />
	//The Main Menu<br />
	char *menu_items[]={ 	&quot;Set Time&quot;,<br />
							&quot;Set Date&quot;,<br />
							&quot;Quit&quot;<br />
						};<br />
	uint8_t menu_count=3;<br />
	uint8_t selected=0;</p>
<p>	_delay_loop_2(0);<br />
	_delay_loop_2(0);</p>
<p>	while(1)<br />
	{<br />
		LCDClear();<br />
		LCDWriteString(&quot;    Main Menu  &quot;);</p>
<p>		LCDWriteStringXY(2,1,menu_items[selected]);</p>
<p>		LCDWriteStringXY(0,1,&quot;&#8221;);</p>
<p>		if(GetKeyStatus(1))<br />
		{<br />
			//Left Key(No 1) is pressed<br />
			//Check that it was not pressed previously<br />
			if(!GetPrevKeyStatus(1))<br />
			{<br />
				if(selected !=0)<br />
					selected&#8211;;<br />
			}<br />
		}</p>
<p>		if(GetKeyStatus(0))<br />
		{<br />
			//Right Key(No 0) is pressed<br />
			//Check that it was not pressed previously<br />
			if(!GetPrevKeyStatus(0))<br />
			{<br />
				if(selected !=(menu_count-1))<br />
					selected++;<br />
			}<br />
		}</p>
<p>		if(GetKeyStatus(2))<br />
		{<br />
			//Enter Key Pressed<br />
			//Check that it was not pressed previously<br />
			if(!GetPrevKeyStatus(2))<br />
			{<br />
				//Call Appropriate Function<br />
				switch (selected)<br />
				{<br />
					case 0:<br />
						SetTime();<br />
						break;<br />
					case 1:<br />
						SetDate();<br />
						break;</p>
<p>					case 2:<br />
						return;//Quit</p>
<p>					//case 3:<br />
					//	return;//Quit<br />
				}</p>
<p>			}<br />
		}</p>
<p>		PREV_PINB=PINB;</p>
<p>		_delay_loop_2(5000);<br />
	}<br />
}</p>
<p>void SetTime()<br />
{</p>
<p>	uint8_t hr,min,sec,temp;</p>
<p>	//Read the Second Register<br />
	DS1307Read(0&#215;00,&amp;temp);<br />
	sec=(((temp &amp; 0b01110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	//Read the Minute Register<br />
	DS1307Read(0&#215;01,&amp;temp);<br />
	min=(((temp &amp; 0b01110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	//Read the Hour Register<br />
	DS1307Read(0&#215;02,&amp;temp);<br />
	hr=(((temp &amp; 0b00110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	uint8_t sel=0;</p>
<p>	while(1)<br />
	{<br />
		LCDClear();</p>
<p>		LCDWriteString(&#8220;00:00:00    &#8220;);</p>
<p>		LCDWriteIntXY(0,0,hr,2);<br />
		LCDWriteIntXY(3,0,min,2);<br />
		LCDWriteIntXY(6,0,sec,2);</p>
<p>		//Draw Pointer<br />
		LCDWriteStringXY(sel*3,1,&#8221;^^&#8221;);</p>
<p>		//Input Up key<br />
		if(GetKeyStatus(1))<br />
		{<br />
			if(!GetPrevKeyStatus(1))<br />
			{<br />
				if(sel==0)<br />
				{<br />
					//Hour<br />
					if(hr==24)<br />
					{<br />
						hr=0;<br />
					}<br />
					else<br />
					{<br />
						hr++;<br />
					}<br />
				}</p>
<p>				if(sel==1)<br />
				{<br />
					//Min<br />
					if(min==59)<br />
					{<br />
						min=0;<br />
					}<br />
					else<br />
					{<br />
						min++;<br />
					}<br />
				}</p>
<p>				if(sel==2)<br />
				{<br />
					//Sec<br />
					if(sec==59)<br />
					{<br />
						sec=0;<br />
					}<br />
					else<br />
					{<br />
						sec++;<br />
					}<br />
				}</p>
<p>				if(sel == 4)<br />
				{<br />
					//OK<br />
					break;<br />
				}<br />
			}<br />
		}</p>
<p>		//Input Down<br />
		if(GetKeyStatus(0))<br />
		{<br />
			if(!GetPrevKeyStatus(0))<br />
			{<br />
				if(sel==0)<br />
				{<br />
					//Hour<br />
					if(hr==0)<br />
					{<br />
						hr=23;<br />
					}<br />
					else<br />
					{<br />
						hr&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel==1)<br />
				{<br />
					//Min<br />
					if(min==0)<br />
					{<br />
						min=59;<br />
					}<br />
					else<br />
					{<br />
						min&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel==2)<br />
				{<br />
					//Sec<br />
					if(sec==0)<br />
					{<br />
						sec=59;<br />
					}<br />
					else<br />
					{<br />
						sec&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel == 4)<br />
				{<br />
					//OK<br />
					break;<br />
				}<br />
			}<br />
		}</p>
<p>		if(GetKeyStatus(2))<br />
		{<br />
			if(!GetPrevKeyStatus(2))<br />
			{<br />
				//Change Selection<br />
				if(sel==4)<br />
					sel=0;<br />
				else<br />
					sel++;<br />
			}<br />
		}</p>
<p>		PREV_PINB=PINB;</p>
<p>		_delay_loop_2(30000);</p>
<p>	}</p>
<p>	//Now write time back to RTC Module<br />
	temp=((sec/10)&lt;&lt;4)|(sec%10);<br />
	DS1307Write(0&#215;00,temp);</p>
<p>	temp=((min/10)&lt;&lt;4)|(min%10);<br />
	DS1307Write(0&#215;01,temp);</p>
<p>	temp=((hr/10)&lt;&lt;4)|(hr%10);<br />
	temp&amp;= ~(0b01000000); // 24 satno vrijeme</p>
<p>	DS1307Write(0&#215;02,temp);</p>
<p>	LCDClear();<br />
	LCDWriteString(&quot;Time Set !&quot;);</p>
<p>	uint8_t i;<br />
	for(i=0;i&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	//Read the Month Register<br />
	DS1307Read(0&#215;05,&amp;temp);<br />
	month=(((temp &amp; 0b00010000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	//Read the Year Register<br />
	DS1307Read(0&#215;06,&amp;temp);<br />
	yr=(((temp &amp; 0b11110000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);</p>
<p>	//Procitaj registar za Dan<br />
	DS1307Read(0&#215;03,&amp;temp);<br />
	dan=temp &amp; 0b00000111;</p>
<p>	uint8_t sel=0;</p>
<p>	while(1)<br />
	{<br />
		LCDClear();</p>
<p>		LCDWriteString(&#8220;00/00 0  00 &#8220;);</p>
<p>		LCDWriteIntXY(0,0,date,2);<br />
		LCDWriteIntXY(3,0,month,2);<br />
		LCDWriteIntXY(6,0,dan,2);<br />
		LCDWriteIntXY(9,0,yr,2);</p>
<p>		//Draw Pointer<br />
		LCDWriteStringXY(sel*3,1,&#8221;^^&#8221;);</p>
<p>		//Input Up key<br />
		if(GetKeyStatus(1))<br />
		{<br />
			if(!GetPrevKeyStatus(1))<br />
			{<br />
				if(sel==0)<br />
				{<br />
					//Date<br />
					if(date==32)<br />
					{<br />
						date=1;<br />
					}<br />
					else<br />
					{<br />
						date++;<br />
					}<br />
				}</p>
<p>				if(sel==1)<br />
				{<br />
					//Month<br />
					if(month==13)<br />
					{<br />
						month=1;<br />
					}<br />
					else<br />
					{<br />
						month++;<br />
					}<br />
				}</p>
<p>				if(sel==2)<br />
				{<br />
					//Dan<br />
					if(dan==8)<br />
					{<br />
						dan=1;<br />
					}<br />
					else<br />
					{<br />
						dan++;<br />
					}<br />
				}</p>
<p>				if(sel==3)<br />
				{<br />
					//Year<br />
					if(yr==99)<br />
					{<br />
						yr=1;<br />
					}<br />
					else<br />
					{<br />
						yr++;<br />
					}<br />
				}</p>
<p>				if(sel == 4)<br />
				{<br />
					//OK<br />
					break;<br />
				}<br />
			}<br />
		}</p>
<p>		//Input Down<br />
		if(GetKeyStatus(0))<br />
		{<br />
			if(!GetPrevKeyStatus(0))<br />
			{<br />
				if(sel==0)<br />
				{<br />
					//Date<br />
					if(date==0)<br />
					{<br />
						date=31;<br />
					}<br />
					else<br />
					{<br />
						date&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel==1)<br />
				{<br />
					//Month<br />
					if(month==0)<br />
					{<br />
						month=12;<br />
					}<br />
					else<br />
					{<br />
						month&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel==2)<br />
				{<br />
					//Dan<br />
					if(dan==0)<br />
					{<br />
						dan=7;<br />
					}<br />
					else<br />
					{<br />
						dan&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel==3)<br />
				{<br />
					//Year<br />
					if(yr==0)<br />
					{<br />
						yr=99;<br />
					}<br />
					else<br />
					{<br />
						yr&#8211;;<br />
					}<br />
				}</p>
<p>				if(sel == 4)<br />
				{<br />
					//OK<br />
					break;<br />
				}<br />
			}<br />
		}</p>
<p>		if(GetKeyStatus(2))<br />
		{<br />
			if(!GetPrevKeyStatus(2))<br />
			{<br />
				//Change Selection<br />
				if(sel==4)<br />
					sel=0;<br />
				else<br />
					sel++;<br />
			}<br />
		}</p>
<p>		PREV_PINB=PINB;</p>
<p>		_delay_loop_2(30000);</p>
<p>	}</p>
<p>	//Now write DATE back to RTC Module<br />
	temp=((date/10)&lt;&lt;4)|(date%10);<br />
	DS1307Write(0&#215;04,temp);</p>
<p>	temp=((month/10)&lt;&lt;4)|(month%10);<br />
	DS1307Write(0&#215;05,temp);</p>
<p>	temp=((yr/10)&lt;&lt;4)|(yr%10);<br />
	DS1307Write(0&#215;06,temp);</p>
<p>	temp=dan%10;<br />
	DS1307Write(0&#215;03,temp);</p>
<p>	LCDClear();<br />
	LCDWriteString(&quot;Date Set !&quot;);</p>
<p>	uint8_t i;<br />
	for(i=0;i&lt;10;i++)<br />
		_delay_loop_2(0);</p>
<p>}</p>
<p>I changed pm/am to 24 hout time and added 1Hz signal output of ds1307.</p>
<p>Regards<br />
Filip</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avinash</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-35710</link>
		<dc:creator>Avinash</dc:creator>
		<pubDate>Sat, 17 Dec 2011 13:30:51 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-35710</guid>
		<description>Just Call
&lt;code&gt;
LCDGotoXY(17,0); //To move cursor off screen
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Just Call<br />
<code><br />
LCDGotoXY(17,0); //To move cursor off screen<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avinash</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-35709</link>
		<dc:creator>Avinash</dc:creator>
		<pubDate>Sat, 17 Dec 2011 13:22:01 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-35709</guid>
		<description>@Filip
Can you share a pic (or video) and your modified code ?</description>
		<content:encoded><![CDATA[<p>@Filip<br />
Can you share a pic (or video) and your modified code ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-35687</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Sat, 17 Dec 2011 09:08:47 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-35687</guid>
		<description>Hi,
I assembled the clock and reprogrammed it a bit so it shows time, date, day in a week. 
On display, there is always a blinking cursor.
How can I remove it? I want display to show only data, without blinking cursor.
Have any idea?

Thanks a lot!
Regards</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I assembled the clock and reprogrammed it a bit so it shows time, date, day in a week.<br />
On display, there is always a blinking cursor.<br />
How can I remove it? I want display to show only data, without blinking cursor.<br />
Have any idea?</p>
<p>Thanks a lot!<br />
Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ali</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-34923</link>
		<dc:creator>Ali</dc:creator>
		<pubDate>Thu, 08 Dec 2011 19:47:33 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-34923</guid>
		<description>Hi Avinash Gupta

I just test your circuite with some modification to run on atmega16.
At first i got in troble. finally by connecting SDA pin of DS1307 to SDA pin of Micro and also SCL pin of DS1307 to SCL pin of Micro my problem solved. In your shematic you connected them in reverse. I mean you connected SDA to SCL and SCL to SDA.
Regards
Ali Hassanpour</description>
		<content:encoded><![CDATA[<p>Hi Avinash Gupta</p>
<p>I just test your circuite with some modification to run on atmega16.<br />
At first i got in troble. finally by connecting SDA pin of DS1307 to SDA pin of Micro and also SCL pin of DS1307 to SCL pin of Micro my problem solved. In your shematic you connected them in reverse. I mean you connected SDA to SCL and SCL to SDA.<br />
Regards<br />
Ali Hassanpour</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hassan shahsavar</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-34537</link>
		<dc:creator>hassan shahsavar</dc:creator>
		<pubDate>Mon, 05 Dec 2011 06:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-34537</guid>
		<description>hi
I am an electrical engineer 
Interested in AVR
I&#039;m happy to help you in this area
h_shahsavar@yahoo.com</description>
		<content:encoded><![CDATA[<p>hi<br />
I am an electrical engineer<br />
Interested in AVR<br />
I&#8217;m happy to help you in this area<br />
<a href="mailto:h_shahsavar@yahoo.com">h_shahsavar@yahoo.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabor</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-34204</link>
		<dc:creator>Gabor</dc:creator>
		<pubDate>Thu, 01 Dec 2011 16:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-34204</guid>
		<description>Dear Avinash Gupta,
 
 First I would like to say gratulations and thank you about your website and projects! They are very useful and great solutions!

 I would like to ask you about this DS1307 project. Is it possible to save a given time point in DS1307? (Beside the current time, I would store an alarm time.)
 If it is possible could you explain me how?

 You mentioned that it is also can handle and following dates, calendars as well. How does it possible to store date and read it back?

Really really thank you your help!

Have a nice day and good projects.

Regards,

Gabor</description>
		<content:encoded><![CDATA[<p>Dear Avinash Gupta,</p>
<p> First I would like to say gratulations and thank you about your website and projects! They are very useful and great solutions!</p>
<p> I would like to ask you about this DS1307 project. Is it possible to save a given time point in DS1307? (Beside the current time, I would store an alarm time.)<br />
 If it is possible could you explain me how?</p>
<p> You mentioned that it is also can handle and following dates, calendars as well. How does it possible to store date and read it back?</p>
<p>Really really thank you your help!</p>
<p>Have a nice day and good projects.</p>
<p>Regards,</p>
<p>Gabor</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DS1307 I2C RTCC Interface using SoftI2C lib &#124; eXtreme Electronics</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-34066</link>
		<dc:creator>DS1307 I2C RTCC Interface using SoftI2C lib &#124; eXtreme Electronics</dc:creator>
		<pubDate>Wed, 30 Nov 2011 13:21:43 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-34066</guid>
		<description>[...] DS1307 module built as shown here. [...]</description>
		<content:encoded><![CDATA[<p>[...] DS1307 module built as shown here. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Software I2C Library for AVR MCUs &#124; eXtreme Electronics</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-33361</link>
		<dc:creator>Software I2C Library for AVR MCUs &#124; eXtreme Electronics</dc:creator>
		<pubDate>Thu, 24 Nov 2011 07:16:52 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-33361</guid>
		<description>[...] use to connect a variety of external peripheral with a microcontroller. Most common are EEPROMs, RTC, Port Expanders etc. Most leading MCUs comes with at least one dedicated I2C host adaptor in built. [...]</description>
		<content:encoded><![CDATA[<p>[...] use to connect a variety of external peripheral with a microcontroller. Most common are EEPROMs, RTC, Port Expanders etc. Most leading MCUs comes with at least one dedicated I2C host adaptor in built. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-33292</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Wed, 23 Nov 2011 14:40:20 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-33292</guid>
		<description>It seems to me that for some reason oscillator stops for a while when pow is switched off-on. In what moment and why I don&#039;t know. In AN from Maxim they said oscilattor can stop when in battery mode if voltage on RTC inputs are higher than battery voltage. So I tought mabye microcontroller sends some pulses after supply is switched from 5V to batt. But it doesn&#039;t make sense because rtc supply and inputs are on same line.</description>
		<content:encoded><![CDATA[<p>It seems to me that for some reason oscillator stops for a while when pow is switched off-on. In what moment and why I don&#8217;t know. In AN from Maxim they said oscilattor can stop when in battery mode if voltage on RTC inputs are higher than battery voltage. So I tought mabye microcontroller sends some pulses after supply is switched from 5V to batt. But it doesn&#8217;t make sense because rtc supply and inputs are on same line.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avinash</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-33127</link>
		<dc:creator>Avinash</dc:creator>
		<pubDate>Tue, 22 Nov 2011 06:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-33127</guid>
		<description>&lt;strong&gt;@Filip,

Thanks for the fine observation. I have too noticed some problems like that but don&#039;t know the real cause. Please, if you or someone finds some clues then please share it.&lt;/strong&gt;</description>
		<content:encoded><![CDATA[<p><strong>@Filip,</p>
<p>Thanks for the fine observation. I have too noticed some problems like that but don&#8217;t know the real cause. Please, if you or someone finds some clues then please share it.</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Filip</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-33063</link>
		<dc:creator>Filip</dc:creator>
		<pubDate>Mon, 21 Nov 2011 13:18:50 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-33063</guid>
		<description>Hi,

I assembled the clock and it works fine for both DS1307 and DS2131 chips. This second one is newer but it works with software aou provided. I compared precision with stopwatch and it was accurate exept when I turn off and on again. After few off-on&#039;s RTC (both chips equally) were late cca 3 sec. So, it seems to me that something happends with rtc during on-off that causes delay. Did anyone notice this, is it normal, and can something be done about it?

Thanks, regards...</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I assembled the clock and it works fine for both DS1307 and DS2131 chips. This second one is newer but it works with software aou provided. I compared precision with stopwatch and it was accurate exept when I turn off and on again. After few off-on&#8217;s RTC (both chips equally) were late cca 3 sec. So, it seems to me that something happends with rtc during on-off that causes delay. Did anyone notice this, is it normal, and can something be done about it?</p>
<p>Thanks, regards&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nikhil</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-26751</link>
		<dc:creator>nikhil</dc:creator>
		<pubDate>Fri, 29 Jul 2011 04:57:49 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-26751</guid>
		<description>sorry i cant find the Ds1307.h and c files were can i download it

thank you</description>
		<content:encoded><![CDATA[<p>sorry i cant find the Ds1307.h and c files were can i download it</p>
<p>thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shobeir</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-24618</link>
		<dc:creator>Shobeir</dc:creator>
		<pubDate>Sat, 25 Jun 2011 20:49:54 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-24618</guid>
		<description>Just appreciate you to publish your knowledge. All the best. Well done!!</description>
		<content:encoded><![CDATA[<p>Just appreciate you to publish your knowledge. All the best. Well done!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cisco</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-18134</link>
		<dc:creator>cisco</dc:creator>
		<pubDate>Sat, 26 Feb 2011 17:01:51 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-18134</guid>
		<description>Oops ! sorry, for a fast previous comment. My problem has already solved !

       DS1307Read(0x02,&amp;temp);
       hr=(((temp &amp; 0b00010000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);
                         &#124;
reading only 4 bit -------</description>
		<content:encoded><![CDATA[<p>Oops ! sorry, for a fast previous comment. My problem has already solved !</p>
<p>       DS1307Read(0&#215;02,&amp;temp);<br />
       hr=(((temp &amp; 0b00010000)&gt;&gt;4)*10)+(temp &amp; 0b00001111);<br />
                         |<br />
reading only 4 bit &#8212;&#8212;-</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cisco</title>
		<link>http://extremeelectronics.co.in/avr-tutorials/interfacing-ds1307-rtc-chip-with-avr-microcontroller/comment-page-1/#comment-18129</link>
		<dc:creator>cisco</dc:creator>
		<pubDate>Sat, 26 Feb 2011 15:06:54 +0000</pubDate>
		<guid isPermaLink="false">http://extremeelectronics.co.in/?p=273#comment-18129</guid>
		<description>Hello, Avinash! I&#039;ve assembled an another device with DS1307 RTC. Your code was helpful for me indeed! Thanks a lot. But there&#039;s one thing that don&#039;t work at all - time format changing. I learned its datasheet several times but sill couldn&#039;t find out. When I set up time like this 19:59:50 - it&#039;s work perfect and show correctly, but after 10 seconds it&#039;s changed to a wrong format 00:00:00. What&#039;s the matter ? Can you give me advice? It seems that your library has restrictions or mistakes, but it&#039;s just my opinion.

With best wishes from Russia !

Code from my project:
int main( void )
{ _delay_loop_2(0);
_delay_loop_2(0);
IND_Init(); // ??????????
OWI_Init(BUS); //1-wire bus
//Initialize I2C Bus
I2CInit(); //i^2c

//Clear CH bit of RTC
#define CH 7
uint8_t hr,min,sec,am_pm,temp;

DS1307Read(0x00,&amp;temp);
//Clear CH Bit
temp&amp;=(~(1&lt;&lt;CH));
DS1307Write(0x00,temp);

//Set 12 Hour Mode
// DS1307Read(0x02,&amp;temp);
//Set 12Hour BIT
// temp&#124;=(0b01000000);
//Write Back to DS1307
// DS1307Write(0x02,temp);

hr=19;
min=59;
sec=50;
//am_pm=1;

//Now write time back to RTC Module
temp=((sec/10)&lt;&lt;4)&#124;(sec%10);
DS1307Write(0x00,temp);

temp=((min/10)&lt;&lt;4)&#124;(min%10);
DS1307Write(0x01,temp);

temp=((hr/10)&lt;&lt;4)&#124;(hr%10);
DS1307Write(0x02,temp);
// if(am_pm)
// {
// temp&#124;=0b00100000;
// temp&#124;=0b00000000;
// }

// temp=0b01100001;
// DS1307Write(0x02,temp);

// uint8_t i;
// for(i=0;i&lt;10;i++)
_delay_loop_2(0);
...
}</description>
		<content:encoded><![CDATA[<p>Hello, Avinash! I&#8217;ve assembled an another device with DS1307 RTC. Your code was helpful for me indeed! Thanks a lot. But there&#8217;s one thing that don&#8217;t work at all &#8211; time format changing. I learned its datasheet several times but sill couldn&#8217;t find out. When I set up time like this 19:59:50 &#8211; it&#8217;s work perfect and show correctly, but after 10 seconds it&#8217;s changed to a wrong format 00:00:00. What&#8217;s the matter ? Can you give me advice? It seems that your library has restrictions or mistakes, but it&#8217;s just my opinion.</p>
<p>With best wishes from Russia !</p>
<p>Code from my project:<br />
int main( void )<br />
{ _delay_loop_2(0);<br />
_delay_loop_2(0);<br />
IND_Init(); // ??????????<br />
OWI_Init(BUS); //1-wire bus<br />
//Initialize I2C Bus<br />
I2CInit(); //i^2c</p>
<p>//Clear CH bit of RTC<br />
#define CH 7<br />
uint8_t hr,min,sec,am_pm,temp;</p>
<p>DS1307Read(0&#215;00,&amp;temp);<br />
//Clear CH Bit<br />
temp&amp;=(~(1&lt;&lt;CH));<br />
DS1307Write(0&#215;00,temp);</p>
<p>//Set 12 Hour Mode<br />
// DS1307Read(0&#215;02,&amp;temp);<br />
//Set 12Hour BIT<br />
// temp|=(0b01000000);<br />
//Write Back to DS1307<br />
// DS1307Write(0&#215;02,temp);</p>
<p>hr=19;<br />
min=59;<br />
sec=50;<br />
//am_pm=1;</p>
<p>//Now write time back to RTC Module<br />
temp=((sec/10)&lt;&lt;4)|(sec%10);<br />
DS1307Write(0&#215;00,temp);</p>
<p>temp=((min/10)&lt;&lt;4)|(min%10);<br />
DS1307Write(0&#215;01,temp);</p>
<p>temp=((hr/10)&lt;&lt;4)|(hr%10);<br />
DS1307Write(0&#215;02,temp);<br />
// if(am_pm)<br />
// {<br />
// temp|=0b00100000;<br />
// temp|=0b00000000;<br />
// }</p>
<p>// temp=0b01100001;<br />
// DS1307Write(0&#215;02,temp);</p>
<p>// uint8_t i;<br />
// for(i=0;i&lt;10;i++)<br />
_delay_loop_2(0);<br />
&#8230;<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Database Caching 11/36 queries in 0.015 seconds using apc
Object Caching 560/566 objects using disk: basic

Served from: extremeelectronics.co.in @ 2012-02-08 11:07:57 -->
