<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=4&amp;t=22106&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2019-03-25T22:40:51+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=22106&amp;mode</id>
<entry>
<author><name><![CDATA[Pixelxx]]></name></author>
<updated>2019-03-25T22:40:51+01:00</updated>
<published>2019-03-25T22:40:51+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217659#p217659</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217659#p217659"/>
<title type="html"><![CDATA[Re: RTC DS3231]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217659#p217659"><![CDATA[
Fakt miałem inne piny ustawione w biblio. Wszystko działa. Dzięki<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=19122">Pixelxx</a> — 25 mar 2019, o 22:40</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[chi.cygni]]></name></author>
<updated>2019-03-25T22:30:24+01:00</updated>
<published>2019-03-25T22:30:24+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217658#p217658</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217658#p217658"/>
<title type="html"><![CDATA[Re: RTC DS3231]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217658#p217658"><![CDATA[
<div class="quotetitle">Pixelxx napisał(a):</div><div class="quotecontent"><br />Zwykłe wyświetlanie na LCD działa.<br />Próba wyświetlenia danych z układu DS3231 jest zerowa.<br /></div><br />To może piny odpowiadające za &quot;zwykłe wyświetlanie na LCD&quot; są inaczej ustawione od pinów z Mirkowej biblioteki.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=3240">chi.cygni</a> — 25 mar 2019, o 22:30</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[anshar]]></name></author>
<updated>2019-03-25T21:53:14+01:00</updated>
<published>2019-03-25T21:53:14+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217656#p217656</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217656#p217656"/>
<title type="html"><![CDATA[Re: RTC DS3231]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217656#p217656"><![CDATA[
Zamiast 32K podłącz SQW.<br />Jaki to uC?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=7157">anshar</a> — 25 mar 2019, o 21:53</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Pixelxx]]></name></author>
<updated>2019-03-25T21:35:58+01:00</updated>
<published>2019-03-25T21:35:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217655#p217655</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217655#p217655"/>
<title type="html"><![CDATA[RTC DS3231]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=22106&amp;p=217655#p217655"><![CDATA[
Witam.<br /><br />Próbowałem uruchomić DS3231 zgodnie z poradnikiem:<br /><!-- m --><a class="postlink" href="http://mirekk36.blogspot.com/2013/11/rtc-ds3231-najdokadniejszy-zegarek-na.html" >http://mirekk36.blogspot.com/2013/11/rt ... ek-na.html</a><!-- m --><br /><br />Po podłączeniu na wyświetlaczu nie ma nic.<br />Zwykłe wyświetlanie na LCD działa.<br />Próba wyświetlenia danych z układu DS3231 jest zerowa.<br />Wyjście 32KHz podłączyłem pod PD2. Reszta to zasilanie oraz I2C.<br />uC to Atmega32 16Mhz<br /><br />[syntax=c]/*<br /> * main.c<br /> *<br /> *  Created on: 01-11-2013<br /> *      Author: Mirosław Karadś<br /> */<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;HD44780/lcd44780.h&quot;<br />#include &quot;I2C_TWI/i2c_twi.h&quot;<br /><br /><br />typedef union {<br />uint8_t bytes&#91;7&#93;;<br />struct {<br />uint8_t ss;<br />uint8_t mm;<br />uint8_t hh;<br />uint8_t dayofwek;<br />uint8_t day;<br />uint8_t month;<br />uint8_t year;<br />};<br />} TDATETIME;<br /><br /><br />typedef struct {<br />int8_t cel;<br />uint8_t fract;<br />} TTEMP;<br /><br /><br />#define DS3231_ADDR 0xD0<br /><br />void DS3231_init( void );<br />uint8_t dec2bcd(uint8_t dec);<br />uint8_t bcd2dec(uint8_t bcd);<br />void DS3231_get_datetime( TDATETIME * dt );<br />void show_time( TDATETIME * dt );<br />void show_date( TDATETIME * dt );<br />void DS3231_set_time( uint8_t hh, uint8_t mm, uint8_t ss );<br />void DS3231_set_date( uint8_t year, uint8_t month, uint8_t day, uint8_t dayofweek );<br />void DS3231_get_temp( TTEMP * tmp );<br />void show_temperature( TTEMP * tmp );<br /><br /><br /><br /><br />TDATETIME datetime;<br />TTEMP temperature;<br /><br />char days&#91;7&#93;&#91;4&#93; = {<br />&quot;pon&quot;, &quot;wto&quot;, &quot;sro&quot;, &quot;czw&quot;, &quot;pia&quot;, &quot;sob&quot;, &quot;nie&quot;<br />};<br /><br />uint8_t stc&#91;&#93; = {12,18,18,12,32,32,32,32};<br /><br />int main( void ) {<br /><br />lcd_init();<br />//lcd_defchar(0, stc);<br />lcd_cls();<br />lcd_str(&quot;start...&quot;);<br /><br />// konfiguracja wejścia INT0<br />PORTD |= (1&lt;&lt;PD2);<br />MCUCR |= (1&lt;&lt;ISC01)|(1&lt;&lt;ISC00); // zbocze narastające<br /><br /><br />i2cSetBitrate(100);<br /><br />DS3231_init();<br /><br />//DS3231_set_time( 17,46,0 );<br />//DS3231_set_date( 13, 10, 31, 4 );<br /><br /> sei();<br />while(1) {<br /><br />if( GIFR &amp; (1&lt;&lt;INTF0) ) {<br /><br />DS3231_get_datetime( &amp;datetime );<br />DS3231_get_temp( &amp;temperature );<br /><br />lcd_locate(0,0);<br />show_date( &amp;datetime );<br /><br />lcd_locate(1,0);<br />show_time( &amp;datetime );<br /><br />lcd_locate(1,9);<br />show_temperature( &amp;temperature );<br /><br />GIFR |= (1&lt;&lt;INTF0);  // kasowanie flagi<br />}<br /><br />}<br />}<br /><br /><br />void DS3231_init( void ) {<br />uint8_t ctrl = 0;<br />TWI_write_buf( DS3231_ADDR, 0x0e, 1, &amp;ctrl );<br />}<br /><br />void DS3231_get_datetime( TDATETIME * dt ) {<br />uint8_t i;<br />uint8_t buf&#91;7&#93;;<br />TWI_read_buf( DS3231_ADDR, 0x00, 7, buf );<br />for( i=0; i&lt;7; i++ ) dt-&gt;bytes&#91;i&#93; = bcd2dec( buf&#91;i&#93; );<br />}<br /><br /><br />void show_time( TDATETIME * dt ) {<br />if( dt-&gt;hh &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;hh);<br />lcd_str(&quot;:&quot;);<br />if( dt-&gt;mm &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;mm);<br />lcd_str(&quot;:&quot;);<br />if( dt-&gt;ss &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;ss);<br />}<br /><br />void show_date( TDATETIME * dt ) {<br />lcd_str(&quot;20&quot;);<br />if( dt-&gt;year &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;year);<br />lcd_str(&quot;-&quot;);<br />if( dt-&gt;month &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;month);<br />lcd_str(&quot;-&quot;);<br />if( dt-&gt;day &lt; 10 ) lcd_str(&quot;0&quot;);<br />lcd_int(dt-&gt;day);<br />lcd_str(&quot;  &quot;);<br />lcd_str( days&#91; dt-&gt;dayofwek - 1 &#93; );<br />}<br /><br />void DS3231_set_time( uint8_t hh, uint8_t mm, uint8_t ss ) {<br />uint8_t buf&#91;3&#93;;<br />buf&#91;0&#93;=dec2bcd(ss);<br />buf&#91;1&#93;=dec2bcd(mm);<br />buf&#91;2&#93;=dec2bcd(hh);<br />TWI_write_buf( DS3231_ADDR, 0x00, 3, buf );<br />}<br /><br />void DS3231_set_date( uint8_t year, uint8_t month, uint8_t day, uint8_t dayofweek ) {<br />uint8_t buf&#91;4&#93;;<br />buf&#91;0&#93;=dayofweek;<br />buf&#91;1&#93;=dec2bcd(day);<br />buf&#91;2&#93;=dec2bcd(month);<br />buf&#91;3&#93;=dec2bcd(year);<br />TWI_write_buf( DS3231_ADDR, 0x03, 4, buf );<br />}<br /><br /><br />void DS3231_get_temp( TTEMP * tmp ) {<br />uint8_t buf&#91;2&#93;;<br />TWI_read_buf( DS3231_ADDR, 0x11, 2, buf );<br />tmp-&gt;cel = buf&#91;0&#93; ;<br />tmp-&gt;fract = buf&#91;1&#93;&gt;&gt;6;<br /><br />TWI_read_buf( DS3231_ADDR, 0x0e, 1, buf );<br />buf&#91;0&#93; |= (1&lt;&lt;5);<br />TWI_write_buf( DS3231_ADDR, 0x0e, 1, buf );<br />}<br /><br /><br />void show_temperature( TTEMP * tmp ) {<br />uint8_t fr&#91;4&#93; = {0,2,5,7};<br /><br />if( tmp-&gt;cel &lt; 100 ) lcd_str(&quot; &quot;);<br />if( tmp-&gt;cel &lt; 10 ) lcd_str(&quot; &quot;);<br /><br />lcd_int(tmp-&gt;cel);<br />lcd_str(&quot;.&quot;);<br />if( tmp-&gt;cel &gt;= 0 ) lcd_int( fr&#91; tmp-&gt;fract &#93; );<br />else lcd_int( fr&#91; 3 - tmp-&gt;fract &#93; );<br /><br />lcd_str(&quot;\x80&quot;&quot;C&quot;);<br />}<br /><br /><br /><br />// konwersja liczby dziesiętnej na BCD<br />uint8_t dec2bcd(uint8_t dec) {<br />return ((dec / 10)&lt;&lt;4) | (dec % 10);<br />}<br /><br />// konwersja liczby BCD na dziesiętną<br />uint8_t bcd2dec(uint8_t bcd) {<br />    return ((((bcd) &gt;&gt; 4) &amp; 0x0F) * 10) + ((bcd) &amp; 0x0F);<br />}[/syntax]<br /><br />Posiadam taki moduł:<br /><br /><a href="https://obrazkiforum.atnel.pl/19122/bc41073526770af1117c37ba5c5a7798.jpg"  class="postlink"><img src="https://obrazkiforum.atnel.pl/thumb/19122/bc41073526770af1117c37ba5c5a7798.jpg" alt="Obrazek" /></a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=19122">Pixelxx</a> — 25 mar 2019, o 21:35</p><hr />
]]></content>
</entry>
</feed>