<html>
<head>
<meta content="text/html; charset=iso-8859-2"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Promenna tmp_counter se vam
inicializuje pri kazdem pruchodu while cyklu na 2048. Aby vam to
fungovalo, musi se inicializovat jen jednou a to pred vstupem to
cyklu, tedy pred while.<br>
Kompilator tmp_count ignoruje, protoze hodnota tmp_count v
podmince vzdy 2047.<br>
<br>
<br>
J.S.<br>
<br>
<br>
<br>
On 02/13/2015 12:54 PM, Michal Lukac wrote:<br>
</div>
<blockquote cite="mid:F8230CF32C6A4488A3E34D2244C6019C@cimml2"
type="cite">
<div dir="ltr">
<div style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial'; COLOR:
#000000">
<div>Zdravim, mam takuto cast kodu:</div>
<div>Tu premennu tmp_counter som chcel definovat vnutri toho
bloku s tim ze bude platna len v tom bloku a </div>
<div>na zaciatku sa inicializuje, kvoli setreniu miesta v
pamati. Lenze to nefunguje prelozi sa to viz. nizsie, ako
keby sa ta hodnota nemenila cize to vsetko potom kompilator
ignoruje</div>
<div>Ked tu definiciu dam pred to while tak to funguje. chcel
som len aby zbytocne nezaberala miesto. Dalo by sa to aj s
cyklom for v tomto pripade, ale ma zaujima ked by tam malo
byt while</div>
<div>Da sa to nejak inak urobit? </div>
<div> </div>
<div>dik.</div>
<div>michal</div>
<div> </div>
<div>uint32_t tmp32 = 0;</div>
<div>uint16_t tmp16;</div>
<div> </div>
<div>while(1){</div>
<div> uint16_t tmp_counter = 2048;</div>
<div> if (bit_is_clear(ADCSRA,ADSC)) {</div>
<div> tmp16 = ADCL; </div>
<div> tmp16 |= ((uint16_t)ADCH << 8);</div>
<div> tmp32 += tmp16;</div>
<div> tmp_counter--;</div>
<div> AD_START;</div>
<div> if (tmp_counter == 0) {</div>
<div> tmp32 >>= 5;</div>
<div> offset_I = tmp32;</div>
<div> </div>
<div> utoa((unsigned int)tmp32,s_out,10);</div>
<div> lcd_gotoxy(0,0);</div>
<div> lcd_puts(s_out);</div>
<div> _delay_ms(3000);</div>
<div> lcd_clrscr();</div>
<div> break; </div>
<div> }</div>
<div> }</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
<div> 245: if (bit_is_clear(ADCSRA,ADSC)) {</div>
<div>0000015E SBIC 0x06,6 Skip if bit in I/O register
cleared </div>
<div>0000015F RJMP PC-0x0001 Relative jump </div>
<div> 246: tmp16 = ADCL; </div>
<div>00000160 IN R24,0x04 In from I/O location </div>
<div> 247: tmp16 |= ((uint16_t)ADCH << 8);</div>
<div>00000161 IN R24,0x05 In from I/O location </div>
<div> 250: AD_START;</div>
<div>00000162 SBI 0x06,6 Set bit in I/O register </div>
<div>00000163 RJMP PC-0x0005 Relative jump </div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<br>
</body>
</html>