<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"Formátovaný v HTML Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.FormtovanvHTMLChar
        {mso-style-name:"Formátovaný v HTML Char";
        mso-style-priority:99;
        mso-style-link:"Formátovaný v HTML";
        font-family:Consolas;}
span.StylE-mailovZprvy20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=CS link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color="#1f497d" face=Calibri><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>A
nemusíš to icr1 nastavovat znovu v přerušení ?<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color="#1f497d" face=Calibri><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></font></p>

<div>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:"Tahoma","sans-serif";font-weight:bold'>From:</span></font></b><font
size=2 face=Tahoma><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>
Hw-list [mailto:hw-list-bounces@list.hw.cz] <b><span style='font-weight:bold'>On
Behalf Of </span></b>Martin Záruba<br>
<b><span style='font-weight:bold'>Sent:</span></b> Tuesday, October 10, 2023
7:52 PM<br>
<b><span style='font-weight:bold'>To:</span></b> Martin Zaruba<br>
<b><span style='font-weight:bold'>Subject:</span></b> Přerušení časovačem na
AtMega<o:p></o:p></span></font></p>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p> </o:p></span></font></p>

<p><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Nastavil
jsem<o:p></o:p></span></font></p>

<div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TCCR1A = </span></font><font size=2 color="#005c5f"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#005C5F'>0</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;</span></font><font size=2 color="#95a5a6"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#95A5A6'>
// Vynulování registru TCCR1A</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TCCR1B = </span></font><font size=2 color="#005c5f"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#005C5F'>0</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;</span></font><font size=2 color="#95a5a6"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#95A5A6'>
// Vynulování registru TCCR1B</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#95A5A6'>  // Nastavení režimu Fast PWM (TOP = ICR1)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TCCR1A |= </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< WGM11</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TCCR1B |= </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< WGM13</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'> | </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< WGM12</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#95A5A6'>  // Nastavení hodinového děliče na 64 (frekvence časovače
= frekvence CPU / 64)</span></font><font size=2 color="#4e5b61" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TCCR1B |= </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< CS11</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'> | </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< CS10</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#95A5A6'>  // Nastavení intervalu pro generování přerušení (100 us)
- pro frekvenci CPU 16 MHz</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#95A5A6'>  // ICR1 = (F_CPU / (časový interval * hodinový dělič)) -
1</span></font><font size=2 color="#4e5b61" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  ICR1 = </span></font><font size=2 color="#005c5f"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#005C5F'>24</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;</span></font><font size=2 color="#95a5a6"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#95A5A6'>
// 100 us při frekvenci CPU 16 MHz a hodinovém děliči 64</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#95A5A6'>  // Povolení přerušení od časovače Timer/Counter1</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>  TIMSK1 |= </span></font><font size=2 color="#434f54"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#005c5f" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#005C5F'>1</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>
<< TOIE1</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>)</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>a rutina přerušení je zatím zcela triviální<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

</div>

<div>

<div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#d35400" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#D35400'>ISR</span></font><font size=2 color="#434f54" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#434F54'>(</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>TIMER1_OVF_vect</span></font><font size=2
color="#434f54" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#434F54'>)</span></font><font size=2 color="#4e5b61" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'> </span></font><font
size=2 color="#434f54" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#434F54'>{</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'> </span></font><font size=2 color="#d35400" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#D35400'>cli</span></font><font
size=2 color="#434f54" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#434F54'>()</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>;</span></font><font
size=2 color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#95A5A6'> // Vypnutí globálních přerušení</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'> PORTA=</span></font><font size=2 color="#005c5f"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#005C5F'>0</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'> PORTA=</span></font><font size=2 color="#005c5f"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#005C5F'>0xFF</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'>;<o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'> </span></font><font size=2 color="#d35400" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#D35400'>sei</span></font><font
size=2 color="#434f54" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#434F54'>()</span></font><font size=2 color="#4e5b61"
face=Consolas><span style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'>;</span></font><font
size=2 color="#95a5a6" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#95A5A6'> // Zapnutí globálních přerušení</span></font><font
size=2 color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:
Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

<div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#434f54" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#434F54'>}</span></font><font size=2 color="#4e5b61" face=Consolas><span
style='font-size:10.5pt;font-family:Consolas;color:#4E5B61'><o:p></o:p></span></font></p>

</div>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'><o:p> </o:p></span></font></p>

<p class=MsoNormal style='line-height:14.25pt;background:white'><font size=2
color="#4e5b61" face=Consolas><span style='font-size:10.5pt;font-family:Consolas;
color:#4E5B61'>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ě?<o:p></o:p></span></font></p>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'> <o:p></o:p></span></font></p>

<pre><font size=2 face="Courier New"><span style='font-size:10.0pt'>-- <o:p></o:p></span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'><o:p> </o:p></span></font></pre><pre><font
size=2 face="Courier New"><span style='font-size:10.0pt'>Martin Záruba<o:p></o:p></span></font></pre></div>

</body>

</html>