<?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=18742&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2017-07-03T07:33:40+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=18742&amp;mode</id>
<entry>
<author><name><![CDATA[wilczakr]]></name></author>
<updated>2017-07-03T07:33:40+01:00</updated>
<published>2017-07-03T07:33:40+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191589#p191589</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191589#p191589"/>
<title type="html"><![CDATA[Re: Extremaly accurate RTC]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191589#p191589"><![CDATA[
Aż mi głupio a przy tym jeszcze tyle czasu nad tym spędziłem. A tyle się mówi o wyłączeniu Debug.<br /><br />Dziękuję i pozdrawiam<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=16932">wilczakr</a> — 3 lip 2017, o 07:33</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[xentis]]></name></author>
<updated>2017-07-03T07:01:55+01:00</updated>
<published>2017-07-03T07:01:55+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191588#p191588</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191588#p191588"/>
<title type="html"><![CDATA[Re: Extremaly accurate RTC]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191588#p191588"><![CDATA[
<div class="quotetitle">wilczakr napisał(a):</div><div class="quotecontent"><br />07:35:00 **** Incremental Build of configuration Debug for project RTC_DS3231 ****<br /></div>Odpowiedź na Twoje problemy jest na samym początku logu z kompilacji. Przełącz projekt na Release a pewnie pójdzie bez zająknięcia.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=6265">xentis</a> — 3 lip 2017, o 07:01</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[wilczakr]]></name></author>
<updated>2017-07-03T06:52:31+01:00</updated>
<published>2017-07-03T06:52:31+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191587#p191587</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191587#p191587"/>
<title type="html"><![CDATA[Extremaly accurate RTC]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18742&amp;p=191587#p191587"><![CDATA[
Witam,<br /> mam problem i proszę o pomoc w sprawie kodu do w/w poradnika pana Mirka. Otóż pobrałem kod z bloga, zaimportowałem do Eclipsa i po kompilacji wyrzuca w całym projekcie &quot;DS3231&quot; błąd. Przejrzałem wszystkie pliki odnośnie LCD i I2C_TWI i ku mojemu zaskoczeniu w żadnym z nich nic nie widać tylko jak wspomniałem wcześniej w całym projekcie. Wkleję poniżej kod programu i wynik po kompilacji bez bibliotek do LCD i I2C które można zaimportować z BLUEBOOK-a i proszę o analizę:<br /><br />[syntax=c]#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;LCD/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 />07:35:00 **** Incremental Build of configuration Debug for project RTC_DS3231 ****<br />make all <br />'Building file: ../main.c'<br />'Invoking: AVR Compiler'<br />avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -std=gnu99 -funsigned-char -funsigned-bitfields -mmcu=atmega32 -DF_CPU=11059200UL -MMD -MP -MF&quot;main.d&quot; -MT&quot;main.o&quot; -c -o &quot;main.o&quot; &quot;../main.c&quot;<br />In file included from ../main.c:12:0:<br />c:\program files (x86)\atmel\avr tools\avr toolchain\avr\include\util\delay.h:95:3: warning: #warning &quot;Compiler optimizations disabled; functions from &lt;util/delay.h&gt; won't work as designed&quot; [-Wcpp]<br /> # warning &quot;Compiler optimizations disabled; functions from &lt;util/delay.h&gt; won't work as designed&quot;<br />   ^<br />'Finished building: ../main.c'<br />' '<br />'Building target: RTC_DS3231.elf'<br />'Invoking: AVR C Linker'<br />avr-gcc -Wl,-Map,RTC_DS3231.map -mmcu=atmega32 -o &quot;RTC_DS3231.elf&quot;  ./LCD/lcd44780.o  ./I2C_TWI/i2c_twi.o  ./main.o   <br />'Finished building target: RTC_DS3231.elf'<br />' '<br />'Invoking: AVR Create Extended Listing'<br />avr-objdump -h -S RTC_DS3231.elf  &gt;&quot;RTC_DS3231.lss&quot;<br />'Finished building: RTC_DS3231.lss'<br />' '<br />'Invoking: Print Size'<br />avr-size --format=avr --mcu=atmega32 RTC_DS3231.elf<br />AVR Memory Usage<br />----------------<br />Device: atmega32<br /><br />Program:    7806 bytes (23.8% Full)<br />(.text + .data + .bootloader)<br /><br />Data:         73 bytes (3.6% Full)<br />(.data + .bss + .noinit)<br /><br /><br />'Finished building: sizedummy'<br />' '<br /><br />07:35:00 Build Finished (took 569ms)<br /><br /><br />Z góry dziękuję za pomoc<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=16932">wilczakr</a> — 3 lip 2017, o 06:52</p><hr />
]]></content>
</entry>
</feed>