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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2022-06-28T07:23:11+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=8&amp;t=24261&amp;mode</id>
<entry>
<author><name><![CDATA[Kuźnia]]></name></author>
<updated>2022-06-28T07:23:11+01:00</updated>
<published>2022-06-28T07:23:11+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235705#p235705</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235705#p235705"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235705#p235705"><![CDATA[
Sprawdź czy po tej modyfikacji przy każdym wywołaniu funkcjia uart_get_string nie zwraca '\r'. Może wtedy dochodzić do nadpisywania wcześniej odebranych i wyświetlonych danych w terminalu.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2537">Kuźnia</a> — 28 cze 2022, o 07:23</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2022-06-26T23:05:59+01:00</updated>
<published>2022-06-26T23:05:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235701#p235701</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235701#p235701"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235701#p235701"><![CDATA[
<div class="quotetitle">antosV10 napisał(a):</div><div class="quotecontent"><br />_delay_ms(1000);<br /></div><br />Nie ma co się dziwić że coś gubi skoro używasz TAK PASKUDNEGO DELAYA, wywal go w diabły.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 26 cze 2022, o 23:05</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[antosV10]]></name></author>
<updated>2022-06-26T09:20:04+01:00</updated>
<published>2022-06-26T09:20:04+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235690#p235690</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235690#p235690"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235690#p235690"><![CDATA[
<div class="quotetitle">mirekk36 napisał(a):</div><div class="quotecontent"><br />dobrze, sorki nie zauważyłem tego uart_getc(); w pętli<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 1 minucie ]</span></strong><br /><br />a sprawdzałeś co zwraca uart_getc(); ? czy tam nie ma tak że jeśli nie dotrze żaden znak to zwraca zero ?<br /></div><br /><br />Faktycznie nie zwróciłem uwagi. Kod lekko zmodyfikowałem i teraz działa prawie dobrze tylko program gubi mi pierwszą literkę. Co mogę z tym zrobić?<br /><br />[syntax=c]char* uart_get_string()<br />{<br />static char result&#91;32&#93;;<br />char data = uart_getc();<br />uint8_t i = 0;<br /><br />while(data != '\n') {<br />if(data == 0) break;<br />data = uart_getc();<br />result&#91;i++&#93; = data;<br />}<br />result&#91;i&#93; = '\r';<br /><br />return result;<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21647">antosV10</a> — 26 cze 2022, o 09:20</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2022-06-26T06:12:27+01:00</updated>
<published>2022-06-26T06:12:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235689#p235689</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235689#p235689"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235689#p235689"><![CDATA[
dobrze, sorki nie zauważyłem tego uart_getc(); w pętli<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 1 minucie ]</span></strong><br /><br />a sprawdzałeś co zwraca uart_getc(); ? czy tam nie ma tak że jeśli nie dotrze żaden znak to zwraca zero ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 26 cze 2022, o 06:12</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[antosV10]]></name></author>
<updated>2022-06-25T23:09:12+01:00</updated>
<published>2022-06-25T23:09:12+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235688#p235688</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235688#p235688"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235688#p235688"><![CDATA[
<div class="quotetitle">mirekk36 napisał(a):</div><div class="quotecontent"><br />że zwiększysz zmienną i ?<br /></div><br /><br />Mi właśnie o to chodzi, że jak wyjdę z funkcji to zmienna i = 0 tak że za każdym jej wywołaniem nie trzeba jej resetować.  Operacja i++ ma zapisywać kolejny odebrany znak do tablicy result pod odpowiednim indeksem.  Na końcu ta tablica ma być zwrócona.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21647">antosV10</a> — 25 cze 2022, o 23:09</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2022-06-25T12:48:39+01:00</updated>
<published>2022-06-25T12:48:39+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235686#p235686</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235686#p235686"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235686#p235686"><![CDATA[
skoro masz w funkcji<br /><br />[syntax=c]uint8_t i = 0;[/syntax]<br /><br />to jak myślisz co się stanie po ponownym wejściu do funkcji ? i znowu będzie =0<br /><br />więc co ci da w pętli while()<br /><br />[syntax=c]result&#91;i++&#93; = data;[/syntax]<br /><br />że zwiększysz zmienną i ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 25 cze 2022, o 12:48</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[antosV10]]></name></author>
<updated>2022-06-25T12:11:02+01:00</updated>
<published>2022-06-25T12:11:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235685#p235685</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235685#p235685"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235685#p235685"><![CDATA[
<div class="quotetitle">micky napisał(a):</div><div class="quotecontent"><br />Jakie taktowanie i czym, jaka prędkość transmisji?<br /></div><br />16MHz zewnętrzny kwarc, prędkość 9600, ale tutaj raczej wszystko mam dobrze bo odbieranie i nadawanie pojedynczych znaków i nadawanie stringów działa idealnie.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21647">antosV10</a> — 25 cze 2022, o 12:11</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[micky]]></name></author>
<updated>2022-06-25T10:58:35+01:00</updated>
<published>2022-06-25T10:58:35+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235684#p235684</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235684#p235684"/>
<title type="html"><![CDATA[Re: UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235684#p235684"><![CDATA[
Jakie taktowanie i czym, jaka prędkość transmisji?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1546">micky</a> — 25 cze 2022, o 10:58</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[antosV10]]></name></author>
<updated>2022-06-25T10:50:00+01:00</updated>
<published>2022-06-25T10:50:00+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235683#p235683</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235683#p235683"/>
<title type="html"><![CDATA[UART problem z odbieraniem całego stringa.]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24261&amp;p=235683#p235683"><![CDATA[
Nie mogę odebrać całego stringa. Stworzyłem funkcje która ma zwrócić wskaźnik do początku tablicy a następnie ten wskaźnik przekazywany jest do funkcji wysyłającej cały string do komputera. Używam do tego 2 atmeg328P jedna wysyła string &quot;hello\n\r&quot; a druga go odbiera i przesyła do komputera. Na terminalu znaki wyświetlą się czasami poprawnie a czasami występuje np. podwojona litear 'l' albo 'o', innym razem string jest cały pocięty i do komputera dochodzą pierwsze 3 litery. Gdzie mam błąd mojej tej funkcji, bo funkcje nadającą  string i odbierającą jeden znak brałem z blue booka.<br /><br />Kod atmegi nadajacej do komputera:<br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;uart.h&quot;<br /><br />#define LED_ON PORTB |= (1 &lt;&lt; PB1);<br />#define LED_OFF PORTB &amp;= ~(1 &lt;&lt; PB1);<br /><br />int main()<br />{<br />uart_init(__UBRR);<br /><br />DDRB |= (1 &lt;&lt; PB1);<br /><br />while(1)<br />{<br />char *data = UART_get_string();<br />uart_send_string(*data);<br /><br />_delay_ms(500);<br />}<br />}[/syntax]<br /><br />Kod atmegi nadjącej do drugiego mikrokontrolera:<br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#include &quot;uart.h&quot;<br /><br />int main()<br />{<br />uart_init(__UBRR);<br /><br />while(1)<br />{<br />//uart_putc('a');<br />UART_send_string(&quot;hello\n\r&quot;);<br />_delay_ms(1000);<br />}<br />}[/syntax]<br /><br />Moja funkcja do odbierania stringa<br />[syntax=c]char* uart_get_string()<br />{<br />static char result&#91;32&#93;;<br />char data = uart_getc();<br />uint8_t i = 0;<br /><br />while(data != '\n'){<br />result&#91;i++&#93; = data;<br />                data = uart_getc();<br />}<br />result&#91;i&#93; = '\r';<br /><br />return result;<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21647">antosV10</a> — 25 cze 2022, o 10:50</p><hr />
]]></content>
</entry>
</feed>