<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><font face="Arial">ATMega2560.</font></p>
<p><font face="Arial">Jak zjistím CLK? Nic jiného jsem nenastavoval.</font><br>
</p>
<pre class="moz-signature" cols="72">Martin Záruba</pre>
<div class="moz-cite-prefix">Dne 10.10.2023 v 20:26 Pavel Hudeček
napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:d30af353-683c-4414-9bcd-6c660520f7a1@seznam.cz">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Přerušení se samo zakáže vstupem do jeho obsluhy a samo povolí
jejím ukončením, takže cli a sei vyhodit.<br>
<br>
Dále by to chtělo vědět, která ATmega, případně i zda/jak má
nastavené s CLK související fuse bity.<br>
<br>
PH<br>
<br>
<div class="moz-cite-prefix">Dne 10.10.2023 v 19:52 Martin Záruba
napsal(a):<br>
</div>
<blockquote type="cite"
cite="mid:63cfec33-7063-d988-2ae0-05e1663eea4b@volny.cz">
<meta http-equiv="content-type" content="text/html;
charset=UTF-8">
<p>Nastavil jsem</p>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #4e5b61;"> TCCR1A = </span><span style="color: #005c5f;">0</span><span style="color: #4e5b61;">;</span><span style="color: #95a5a6;"> // Vynulování registru TCCR1A</span></div><div><span style="color: #4e5b61;"> TCCR1B = </span><span style="color: #005c5f;">0</span><span style="color: #4e5b61;">;</span><span style="color: #95a5a6;"> // Vynulování registru TCCR1B</span></div>
<div><span style="color: #95a5a6;"> // Nastavení režimu Fast PWM (TOP = ICR1)</span></div><div><span style="color: #4e5b61;"> TCCR1A |= </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << WGM11</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div><div><span style="color: #4e5b61;"> TCCR1B |= </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << WGM13</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;"> | </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << WGM12</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div>
<div><span style="color: #95a5a6;"> // Nastavení hodinového děliče na 64 (frekvence časovače = frekvence CPU / 64)</span></div><div><span style="color: #4e5b61;"> TCCR1B |= </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << CS11</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;"> | </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << CS10</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div>
<div><span style="color: #95a5a6;"> // Nastavení intervalu pro generování přerušení (100 us) - pro frekvenci CPU 16 MHz</span></div><div><span style="color: #95a5a6;"> // ICR1 = (F_CPU / (časový interval * hodinový dělič)) - 1</span></div><div><span style="color: #4e5b61;"> ICR1 = </span><span style="color: #005c5f;">24</span><span style="color: #4e5b61;">;</span><span style="color: #95a5a6;"> // 100 us při frekvenci CPU 16 MHz a hodinovém děliči 64</span></div>
<div><span style="color: #95a5a6;"> // Povolení přerušení od časovače Timer/Counter1</span></div><div><span style="color: #4e5b61;"> TIMSK1 |= </span><span style="color: #434f54;">(</span><span style="color: #005c5f;">1</span><span style="color: #4e5b61;"> << TOIE1</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;">;</span></div>
</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">a rutina přerušení je zatím zcela triviální</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;">
</div>
<div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div style="color: #4e5b61;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #d35400;">ISR</span><span style="color: #434f54;">(</span><span style="color: #4e5b61;">TIMER1_OVF_vect</span><span style="color: #434f54;">)</span><span style="color: #4e5b61;"> </span><span style="color: #434f54;">{</span></div><div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">cli</span><span style="color: #434f54;">()</span><span style="color: #4e5b61;">;</span><span style="color: #95a5a6;"> // Vypnutí globálních přerušení</span></div><span style="color: #4e5b61;"> PORTA=</span><span style="color: #005c5f;">0</span><span style="color: #4e5b61;">;</span><div><span style="color: #4e5b61;"> PORTA=</span><span style="color: #4e5b61;"></span><span style="color: #005c5f;">0xFF</span><span style="color: #4e5b61;">;</span></div><span style="color: #4e5b61;"> </span><span style="color: #d35400;">sei</span><span style="color: #434f54;">()</span><span style="color: #4e5b61;">;</span><span style="color: #95a5a6;"> // Zapnutí globálních přerušení</span><div><span style="color: #434f54;">}</span></div>
Na všech bitech portu A jsou krásné obdélnikové pulzy. Ale perioda vyvolání pulzů je sice cca 100uS ale chaoticky kolísá. Co dělám blbě?
</div></div>
<span style="white-space: pre-wrap">
</span></blockquote>
<br>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-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>
</body>
</html>