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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2018-01-03T00:27:22+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=19896&amp;mode</id>
<entry>
<author><name><![CDATA[Zealota]]></name></author>
<updated>2018-01-03T00:27:22+01:00</updated>
<published>2018-01-03T00:27:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201408#p201408</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201408#p201408"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201408#p201408"><![CDATA[
<div class="quotetitle">StaryAnoda napisał(a):</div><div class="quotecontent"><br />Ok to tak nie wiem czy powinienem się chwalić tym programem ale macie <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br />Wiadomo ta pętla (for(volatile uint32_t I = 0; I != 1000000; I++){}<br />) zastępuję opóźnienie około 750 ms.<br /></div><br />Domyślnie w większości przykładów czy bibliotek do STM Systick sobie tyka sobie co 1 ms.<br />Proste kopiuj wklej z Bluebooka obsługi soft timerów i problem rozwiązany, choćby tak:<br />[syntax=c]void HAL_SYSTICK_Callback( void ) {<br />sk_encoder_proc(); // Funkcja od Sylwka<br /><br />register uint16_t n;<br />n = softTimer1;<br />if (n)softTimer1 = --n;<br /><br />n = softTimer2;<br />if (n) softTimer2 = --n;<br />}<br /><br />int main (void) {<br />    if (softTimer1 == 0) {<br />        softTimer1 = 750;<br />}[/syntax]<br /><br />Piszę to głównie po to by wskazać jak łatwo można łączyć światy AVR z STM.<br />Jak czerpać wiedzę z KolorBooków i bezpośrednio używać jej do np STM32.<br />Do takiego kodu dorzucamy jeszcze obsługę enkodera od Sylwka i już połowa projektu załatwiona.<br />To takie noworoczne przemyślenia, poza tematem <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> ale czasami warto zatrzymać się przy refleksji... <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br />Wszystkiego najlepszego w Nowym Roku <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=16487">Zealota</a> — 3 sty 2018, o 00:27</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[StaryAnoda]]></name></author>
<updated>2018-01-02T16:40:16+01:00</updated>
<published>2018-01-02T16:40:16+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201380#p201380</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201380#p201380"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201380#p201380"><![CDATA[
Ok to tak nie wiem czy powinienem się chwalić tym programem ale macie <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br />Wiadomo ta pętla (for(volatile uint32_t I = 0; I != 1000000; I++){}<br />) zastępuję opóźnienie około 750 ms. Wiadomo w wersji finalnej trzeba to zastąpić timerem<br /><br />Kod do odczytu temperatury z DS18B20:<br /><br />[syntax=c]/*<br /> *<br /> * StaryAnoda<br /> *<br /> */<br />#include &lt;STM32F411xE.h&gt;<br />#include &lt;stdlib.h&gt;<br /><br />void Send_Data(uint8_t Byte);<br />uint8_t One_Wire_Reset(void);<br />void Send_Byte(uint8_t Value);<br />uint8_t Read_Byte(void);<br />uint8_t Read_Bit(void);<br /><br />uint8_t Byte_0;<br />uint8_t Byte_1;<br />uint16_t Temp_Int;<br />float Temperature;<br /><br /><br />int main(void)<br />{<br />RCC -&gt; AHB1ENR |= RCC_AHB1ENR_GPIOAEN;<br />RCC -&gt; APB1ENR |= RCC_APB1ENR_USART2EN;<br /><br />__DSB();<br /><br />// Config for TX<br />GPIOA -&gt; MODER |= GPIO_MODER_MODER2_1;<br />GPIOA -&gt; AFR&#91;0&#93; |= 0b011100000000;<br /><br />// Config for RX<br />GPIOA -&gt; MODER |= GPIO_MODER_MODER3_1;<br />GPIOA -&gt; OTYPER |= GPIO_OTYPER_OT_3;<br />GPIOA -&gt; AFR&#91;0&#93; |= 0b0111000000000000;<br />//<br />USART2-&gt;CR1 = USART_CR1_UE  | USART_CR1_TE | USART_CR1_RE;<br /><br /><br />while(1)<br />{<br />if(One_Wire_Reset())<br />{<br />Send_Byte(0xCC);<br />Send_Byte(0x44);<br /><br />for(volatile uint32_t I = 0; I != 1000000; I++){}<br /><br />if(One_Wire_Reset())<br />{<br />Send_Byte(0xCC);<br />Send_Byte(0xBE);<br /><br />Byte_0 = Read_Byte();<br />Byte_1 = Read_Byte();<br /><br />Temp_Int = (uint16_t)(Byte_0 | (Byte_1 &lt;&lt; 8));<br /><br />if(Byte_1 &amp; 0b11111000)<br />{<br />Temp_Int = ~Temp_Int;<br />Temp_Int = Temp_Int ++;<br />Temperature =  (float)(Temp_Int * -0.0625);<br />}<br />else<br />{<br />Temperature =  (float)(Temp_Int * 0.0625);<br />}<br />}<br />}<br />}<br />return EXIT_SUCCESS;<br />}<br /><br />void Send_Data(uint8_t Byte)<br />{<br />while(!(USART2 -&gt; SR &amp; USART_SR_TXE));<br />USART2 -&gt; DR = Byte;<br />}<br /><br />uint8_t One_Wire_Reset(void)<br />{<br />uint8_t receive = 0, results = 0;<br />USART2 -&gt; BRR = (16000000/9600);<br /><br />Send_Data(0xF0);<br /><br />while(!(USART2 -&gt; SR &amp; USART_SR_RXNE));<br /><br />receive = USART2 -&gt; DR;<br />if(receive != 0xF0)<br />{<br />results = 1;<br />}<br />else<br />{<br />results = 0;<br />}<br />USART2 -&gt; BRR = (16000000/115200);<br />return results;<br />}<br /><br />void Send_Byte(uint8_t Value)<br />{<br />uint16_t i,tmp, receive;<br />for (i = 0; i &lt; 8; i++)<br />{<br />tmp = Value &gt;&gt; i;<br />tmp &amp;= 0x01;<br />if(tmp)<br />{<br />Send_Data(0xFF);<br />}<br />else<br />{<br />Send_Data(0x00);<br />}<br />while(!(USART2 -&gt; SR &amp; USART_SR_RXNE));<br />receive = USART2 -&gt; DR;<br />}<br />}<br /><br />uint8_t Read_Byte(void)<br />{<br />uint8_t i,value=0;<br />for (i = 0; i &lt; 8; i++)<br />{<br />if(Read_Bit())<br />value |= 0x01 &lt;&lt; i;<br />}<br />return value;<br />}<br /><br />uint8_t Read_Bit(void)<br />{<br />uint8_t receive = 0;<br />uint16_t data = 0;<br />Send_Data(0xFF);<br /><br />while(!(USART2 -&gt; SR &amp; USART_SR_RXNE));<br />data = USART2 -&gt; DR;<br /><br />if(data == 255)<br />{<br />receive = 1;<br />}<br />else<br />{<br />receive = 0;<br />}<br />return receive;<br />}<br /><br />//! @}<br />//! @}[/syntax]<br /><br />W niedalekiej przyszłości zaprezentuję kod już bardziej strawny. Jednak wydaję mi się, że po tym co zamieścilem idea jest już zrozumiała <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br /><br />Wada jest taka że po odłączeniu i podłączeniu czujnika będzie ciągle wskazywał -0.0 do ponownego zresetowania programu<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12916">StaryAnoda</a> — 2 sty 2018, o 16:40</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mikandrzej]]></name></author>
<updated>2018-01-02T15:06:31+01:00</updated>
<published>2018-01-02T15:06:31+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201376#p201376</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201376#p201376"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201376#p201376"><![CDATA[
<div class="quotetitle">StaryAnoda napisał(a):</div><div class="quotecontent"><br />Jeżeli jesteś chętny to mogę wrzucić przykład dla STM32F411CE jak uporządkuję kod.<br /></div><br /><br />Oczywiście jeśli będziesz miał możliwość, to chętnie <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br /><br /><div class="quotetitle">Nefarious19 napisał(a):</div><div class="quotecontent"><br />Ja zrobiłem na delayach biblioteke pod F103. Trzeba dożycia powołać timer co tyka co 5us i wywoływać w nim funkcje delaydecrement. Działa ok. Też chcę to przeportowac pod uart.<br /></div><br /><br />To również nie jest zła opcja. Będę próbował podobnie <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> Dzięki!<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=431">mikandrzej</a> — 2 sty 2018, o 15:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Nefarious19]]></name></author>
<updated>2018-01-02T10:48:48+01:00</updated>
<published>2018-01-02T10:48:48+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201364#p201364</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201364#p201364"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201364#p201364"><![CDATA[
Ja zrobiłem na delayach biblioteke pod F103. Trzeba dożycia powołać timer co tyka co 5us i wywoływać w nim funkcje delaydecrement. Działa ok. Też chcę to przeportowac pod uart.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2500">Nefarious19</a> — 2 sty 2018, o 10:48</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[StaryAnoda]]></name></author>
<updated>2018-01-02T08:04:02+01:00</updated>
<published>2018-01-02T08:04:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201357#p201357</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201357#p201357"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201357#p201357"><![CDATA[
Jeżeli jesteś chętny to mogę wrzucić przykład dla STM32F411CE jak uporządkuję kod.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12916">StaryAnoda</a> — 2 sty 2018, o 08:04</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mikandrzej]]></name></author>
<updated>2018-01-02T01:15:42+01:00</updated>
<published>2018-01-02T01:15:42+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201356#p201356</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201356#p201356"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201356#p201356"><![CDATA[
<div class="quotetitle">anshar napisał(a):</div><div class="quotecontent"><br /><a href="https://cnnblike.com/post/stm32-OneWire/"  class="postlink">https://cnnblike.com/post/stm32-OneWire/</a><br /></div><br /><br />Dziękuję! Wygląda to nieźle <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> Jutro przetestuję.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=431">mikandrzej</a> — 2 sty 2018, o 01:15</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[anshar]]></name></author>
<updated>2018-01-02T00:50:46+01:00</updated>
<published>2018-01-02T00:50:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201355#p201355</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201355#p201355"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201355#p201355"><![CDATA[
<a href="https://cnnblike.com/post/stm32-OneWire/"  class="postlink">https://cnnblike.com/post/stm32-OneWire/</a><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=7157">anshar</a> — 2 sty 2018, o 00:50</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mikandrzej]]></name></author>
<updated>2018-01-02T00:33:23+01:00</updated>
<published>2018-01-02T00:33:23+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201354#p201354</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201354#p201354"/>
<title type="html"><![CDATA[Re: 1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201354#p201354"><![CDATA[
Z tego co widzę, to w tym artykule jest opisane jak używać timera do tego celu, nie UART. Też jest to jakaś opcja, ale wolałbym wersje z UARTEM <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br /><br />Dzięki <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br /><br />Wysłane z mojego Redmi Note 4 przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=431">mikandrzej</a> — 2 sty 2018, o 00:33</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mikandrzej]]></name></author>
<updated>2018-01-01T22:50:02+01:00</updated>
<published>2018-01-01T22:50:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201350#p201350</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201350#p201350"/>
<title type="html"><![CDATA[1-wire sterowane sprzętowo przez USART]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=19896&amp;p=201350#p201350"><![CDATA[
Witam.<br /><br />Natknąłem się na możliwość dogadywania się m.in. z czujnikami temperatury DS18B20 przez magistralę 1Wire sterowaną sprzętowo przez UART. Do poszukiwać natchnęła mnie wypowiedź z elektrody:<br /><br /><div class="quotetitle">Freddie Chopin napisał(a):</div><div class="quotecontent"><br />Zrób 1-wire na UARTcie, robienie tego inaczej jest zupełnie bezsensowne.<br /><br />4\/3!!<br /></div><br /><br />Do tego znalazłem poradę od producenta:<br /><br />&quot;TUTORIAL 214 <br />Using a UART to Implement a 1-Wire Bus Master&quot;<br /><a href="https://www.maximintegrated.com/en/app-notes/index.mvp/id/214"  class="postlink">https://www.maximintegrated.com/en/app-notes/index.mvp/id/214</a><br /><br />Czy ma ktoś z tym jakieś doświadczenie? Być może jakieś kody/przykłady?<br />Oczywiście jeśli nie, to sam będę odkrywał koło na nowo, aczkolwiek być może z Waszą pomocą nie będzie to konieczne:)<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=431">mikandrzej</a> — 1 sty 2018, o 22:50</p><hr />
]]></content>
</entry>
</feed>