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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2017-09-20T20:51:02+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=46&amp;t=19240&amp;mode</id>
<entry>
<author><name><![CDATA[michaeleagle]]></name></author>
<updated>2017-09-20T20:51:02+01:00</updated>
<published>2017-09-20T20:51:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19240&amp;p=195512#p195512</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19240&amp;p=195512#p195512"/>
<title type="html"><![CDATA[STM32F3-RTC-TIME/DATA]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19240&amp;p=195512#p195512"><![CDATA[
Cześć!<br /><br />Napisałem prosty program do wyświetlania czasu pracy mikrokontrolera od uruchomienia, na LCD z wykorzystaniem wbudowanego układu RTC.<br />Korzystam z bibliotek HAL. Nie interesuje mnie data, tylko czas więc w funckji konfigurującej RTC, za pomocą funkcji <strong>HAL_RTC_SetTime</strong> ustawiam tylko czas(na 0:0:0). Oczywiście chcę wyświetlać na LCD czas co 1s więc napisałem funckję:<br /><br />[syntax=c]void RTC_TimeShow(void)<br />{<br />RTC_TimeTypeDef  RTC_time_struct_get;/**&lt; Time get structure */<br />RTC_DateTypeDef  RTC_date_struct_get;/**&lt; Date get structure */<br /><br />HAL_RTC_GetTime(&amp;RTC_handle_struct,&amp;RTC_time_struct_get,RTC_FORMAT_BIN);<br />HAL_RTC_GetDate(&amp;RTC_handle_struct,&amp;RTC_date_struct_get,RTC_FORMAT_BIN);  //Bez tego nie działa<br /><br />unsigned char time&#91;50&#93;;/**&lt; Buffer for time string */<br /><br />//Using spritf() to make a string<br />sprintf((char *)time,&quot;%.2d:%.2d:%.2d&quot;,RTC_time_struct_get.Hours,RTC_time_struct_get.Minutes,RTC_time_struct_get.Seconds);<br /><br />//Sending data to LCD<br />LCD_Clear();<br />LCD_WriteText(time);<br />}[/syntax]<br /><br /><br />Jednakże zaobserwowałem, że jeśli używając funckji <strong>HAL_RTC_GetTime</strong> nie użyję funkcji <strong>HAL_RTC_GetDate</strong> to na LCD wyświetla się ten sam czas(bez aktualizacji co 1s, która nomen omen znajduję się w funckji main).<br /><br />Jeżeli użyję obu funkcji to wszystko działa pięknie <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /> <br /><br />Dlaczego tak jest?<br />Czemu, jeżeli używam tylko SetTime to nie mogę użyć tylko GetTime?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=16396">michaeleagle</a> — 20 wrz 2017, o 20:51</p><hr />
]]></content>
</entry>
</feed>