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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2022-09-15T16:48:46+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=24311&amp;mode</id>
<entry>
<author><name><![CDATA[Marhef]]></name></author>
<updated>2022-09-15T16:48:46+01:00</updated>
<published>2022-09-15T16:48:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235999#p235999</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235999#p235999"/>
<title type="html"><![CDATA[Re: integer overflow in expression]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235999#p235999"><![CDATA[
Jeżeli liczbę masz typu uint16_t, a wyświetlasz przez uart_INT, to wyświetli Ci się wynik jako int<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12752">Marhef</a> — 15 wrz 2022, o 16:48</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2022-09-15T15:56:45+01:00</updated>
<published>2022-09-15T15:56:45+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235998#p235998</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235998#p235998"/>
<title type="html"><![CDATA[Re: integer overflow in expression]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235998#p235998"><![CDATA[
wklej taki sam prosty kod testowy po poprawkach a nie coś takiego - kobyłę z pokomentowanymi liniami i nie wiadomo w ogóle o co chodzi<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 15 wrz 2022, o 15:56</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Acade]]></name></author>
<updated>2022-09-15T13:26:06+01:00</updated>
<published>2022-09-15T13:26:06+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235997#p235997</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235997#p235997"/>
<title type="html"><![CDATA[Re: integer overflow in expression]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235997#p235997"><![CDATA[
Panie Mirku dziękuję za podpowiedź.<br />Ale... Niby wszystko jest już zrozumiałe, a i tak coś nie działa.Pewnie mam jakiegoś babola, którego nie widzę. Robiłem różne próby i nic :/<br /><br />Mianowicie przy takim wyrażeniu:<br /><br />[syntax=c]wynik = 22 * 1 *2957;[/syntax]<br /><br />gdzie: <br /><br />[syntax=c]uint16_t wynik = 0;[/syntax]<br /><br />na terminalu otrzymuję wartość -482.  <img src="https://forum.atnel.pl/images/smilies/icon_question.gif" alt=":?:" title="Znak zapytania" /> <br /><br />Robiłem na różne sposoby, te podane w artykule, dodając nawiasy między poszczególne mnożenia i nic dalej -482. <br />Co może być nie tak ?? Wrzucam mojego maina, gdzie za komentowałem już większość kodu, żeby sprawdzić czy czasem coś nie psuje mi tych obliczeń.<br /><br />[syntax=c]#include &lt;avr/interrupt.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br />#define LED (1&lt;&lt;PC3)<br />#define REGISTER_LED DDRC<br />#define LED_PORT PORTC<br />#define LED_TOG PORTC ^= (1&lt;&lt;PC3)<br /><br /><br /><br /><br />#include &quot;UART/uart.h&quot;<br /><br />   <br />      <br />  <br /><br /><br />int main(void)<br />{<br />Uart_Init(103);<br /><br />uint16_t wynik = 0;<br />//uint32_t pm = 22;<br /><br />//uint32_t i = 0;<br />//uint8_t adc_value = 0;<br />//uint32_t voltage = 0;<br />//uint8_t wspolczynnik_podzialu = 21;<br />//uint8_t cz_d = 0;<br />//uint8_t cz_u = 0;<br /><br /><br /><br /><br />///////  Konfiguracja przetwornika ADC<br /><br />ADCSRA |= (1&lt;&lt;ADEN);  //   Włączenie modułu ADC oraz u<br />ADMUX  |= (1&lt;&lt;REFS0) | (1&lt;&lt;REFS1); // Ustawienie napięcia odniesienia 1,1V<br />ADCSRA |= (1&lt;&lt;ADPS2) | (1&lt;&lt;ADPS1) | (1&lt;&lt;ADPS0); // Ustawienie preskalera 128<br />ADMUX  |= (1&lt;&lt;MUX0);  // Wybranie aktywnego kanału ADC  // Kanał ADC 1<br /><br /><br /><br /><br /><br />/*char cls&#91;&#93; = &quot;\x1b&quot;&quot;&#91;2J&quot;;  // clean*/<br />char cursor_off&#91;&#93; = &quot;\x1b&quot;&quot;&#91;?25l&quot;;  // clean<br /><br /><br /><br /><br /><br />    <br />REGISTER_LED |= LED;<br />LED_PORT |= LED;<br /><br />uart_puts(&quot;\x1b&quot;&quot;&#91;2J&quot;);  //  clean<br />uart_puts(&quot;\x1b&quot;&quot;&#91;?25l&quot;); // kursor off<br /><br /><br /><br />    while (1) <br />    {<br /><br />uart_puts(cursor_off); // kursor off<br /> term_attr( 0, YELLOW, BLACK );<br />term_locate(8,2);uart_puts(&quot;Wynik:&quot;);<br /> term_locate(9,5); uart_INT(wynik);<br /> <br /> <br /> wynik = 22 * 1 *2957;<br /> <br /><br /><br /><br /><br /><br />//uart_puts(cls);  //  clean<br />// uart_puts(cursor_off); // kursor off<br />// <br />// <br />// term_attr( 0, BLACK, YELLOW );<br />// term_locate(2,5); uart_puts(&quot;    Test &quot;);<br />// <br />// term_attr( 0, CYAN, BLACK );<br />// term_locate(4,5); uart_puts(&quot;1. Napięcie w punkcie TP3:&quot;);<br />// term_locate(5,5); uart_puts(&quot;2. Napięcie w punkcie TP4:&quot;);<br />// term_locate(6,5); uart_puts(&quot;3. Napięcie w punkcie TP19:&quot;);<br /><br /><br /><br />// term_attr( 0, YELLOW, BLACK );<br />// term_locate(8,5); uart_INT();<br />// uart_puts(&quot;   wartość pm&quot;);<br /><br /><br />// term_locate(13,5); uart_INT(Dist);<br />// uart_puts(&quot;   Dist&quot;);<br /><br />// term_locate(10,5); uart_INT(cz_d);<br />// uart_puts(&quot;,&quot;);<br />// uart_INT(cz_u);<br />// uart_puts(&quot;V&quot;);<br /><br /><br />// term_locate(10,0);<br />// term_attr( 0, CYAN, BLACK );<br />// term_draw_line('-',30);<br />// term_locate(15,0);<br />// term_draw_vertical_line('*',2,20);<br />// LED_TOG;<br />// _delay_ms(1000);<br /><br /><br />       ADCSRA |= (1&lt;&lt;ADSC); //ADSC: uruchomienie pojedynczej konwersji<br />       while(ADCSRA &amp; (1&lt;&lt;ADSC)); //czeka na zakończenie konwersji<br />    }<br />}<br /><br />void USART_Init(unsigned int ubrr)<br />{<br />/*Set baud rate */<br />UBRR0H = (unsigned char)(ubrr&gt;&gt;8);<br />UBRR0L = (unsigned char)ubrr;<br /><br />UCSR0B = (1&lt;&lt;RXEN0)|(1&lt;&lt;TXEN0);<br />/* Set frame format: 8data, 2stop bit */<br />UCSR0C = (1&lt;&lt;USBS0)|(3&lt;&lt;UCSZ00);<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21799">Acade</a> — 15 wrz 2022, o 13:26</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[mirekk36]]></name></author>
<updated>2022-09-15T10:37:10+01:00</updated>
<published>2022-09-15T10:37:10+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235996#p235996</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235996#p235996"/>
<title type="html"><![CDATA[Re: integer overflow in expression]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235996#p235996"><![CDATA[
poczytaj sobie o domyślnej promocji do int<br /><br /><!-- m --><a class="postlink" href="https://atnel.pl/domyslna-promocja-do-typu-int.html" >https://atnel.pl/domyslna-promocja-do-typu-int.html</a><!-- m --><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=54">mirekk36</a> — 15 wrz 2022, o 10:37</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Acade]]></name></author>
<updated>2022-09-15T09:33:25+01:00</updated>
<published>2022-09-15T09:33:25+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235995#p235995</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235995#p235995"/>
<title type="html"><![CDATA[integer overflow in expression]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24311&amp;p=235995#p235995"><![CDATA[
Cześć,<br /><br />po skompilowaniu programu dostaje taki błąd:<br />integer overflow in expression<br /><br />Rozumiem co to jest, ale nie umiem temu zaradzić. Więc jakby ktoś z Was mógł podpowiedzieć co trzeba zrobić i dlaczego tak a nie inaczej.<br />Błąd dotyczy zmiennej voltage.<br />Kod poniżej:<br /><br />[syntax=c]#include &lt;avr/interrupt.h&gt;<br />#include &lt;stdio.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br /><br /><br />int main(void)<br />{<br /><br />uint32_t voltage = 0;<br />uint8_t cz_d = 0;<br />uint8_t cz_u = 0;<br /><br /><br />    while (1) <br />    {<br /><br />voltage = 988 * 21 * 11;<br />cz_d = voltage / 10000;<br />cz_u = (voltage/ 100)  %100 ;<br />       }<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=21799">Acade</a> — 15 wrz 2022, o 09:33</p><hr />
]]></content>
</entry>
</feed>