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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-12-20T13:36:40+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=9773&amp;mode</id>
<entry>
<author><name><![CDATA[Marcin_G]]></name></author>
<updated>2014-12-20T13:36:40+01:00</updated>
<published>2014-12-20T13:36:40+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109642#p109642</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109642#p109642"/>
<title type="html"><![CDATA[Re: Problem z PWM-em]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109642#p109642"><![CDATA[
<div class="quotetitle">sebbek napisał(a):</div><div class="quotecontent"><br />void timer_init()<br />{<br />    TCCR1A = (_BV(COM1A1) | _BV(COM1B1));<br />    TCCR1A |=_BV(WGM10);<br />    TCCR1B =_BV(WGM12) |_BV(CS10);<br />    DDRB |= (_BV(PB3) | _BV(PB4));<br />}<br />[/syntax]<br /></div><br /><br />To co powyżej zamień na:<br /><br />[syntax=c]void timer_init()<br />{<br />    TCCR1A |= (1 &lt;&lt; COM1A1 | 1 &lt;&lt; COM1B1);<br />    TCCR1A |= (1 &lt;&lt; WGM10);<br />    TCCR1B |= (1 &lt;&lt; WGM12 | 1 &lt;&lt; CS10);<br />    DDRB |= (1 &lt;&lt; PB3 | 1 &lt;&lt; PB4);<br />}[/syntax]<br /><br />będzie ładniej <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> i współcześnie <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=758">Marcin_G</a> — 20 gru 2014, o 13:36</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[sebbek]]></name></author>
<updated>2014-12-20T13:31:13+01:00</updated>
<published>2014-12-20T13:31:13+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109640#p109640</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109640#p109640"/>
<title type="html"><![CDATA[Re: Problem z PWM-em]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109640#p109640"><![CDATA[
Dzięki Marcin_G ale już sobie poradziłem <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br /><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 /><br />uint8_t tab1&#91;&#93;={0,1,2,4,8,16,32,0,32,16,8,4,2,1,0};<br />uint8_t tab2&#91;&#93;={63,0};<br />uint8_t tab3&#91;&#93;={0,1,3,7,15,31,63,  0,  63,31,15,7,3,1,0,  63,0,63,0,  7,56,7,56,7,56};<br />uint8_t tab4&#91;&#93;={0,1,3,7,15,31,63,  0,  7,0,7,0,7,0,  56,0,56,0,56,0,  21,42,21,42,21,42,0};<br /><br /><br /><br />uint8_t tab_pwm_A_1&#91;&#93;={255,   0,0};<br />uint8_t tab_pwm_B_1&#91;&#93;={  0, 255,0};<br /><br /><br /><br />void timer_init()<br />{<br />    TCCR1A = (_BV(COM1A1) | _BV(COM1B1));<br />    TCCR1A |=_BV(WGM10);<br />    TCCR1B =_BV(WGM12) |_BV(CS10);<br />    DDRB |= (_BV(PB3) | _BV(PB4));<br />}<br /><br />uint8_t i,jasnosc,a,b=0;<br /><br />int main(void)<br />{<br />    timer_init();<br />    DDRD = 0xff;<br />    PORTD = 0x00;<br /><br />      while(1){<br /><br />  if(0 == jasnosc){<br />        for(jasnosc = 0; jasnosc&lt;255; jasnosc++){<br /><br />            OCR1A = jasnosc;<br />            OCR1B = jasnosc;<br />            _delay_ms(10);<br />            }<br />        }<br /><br />_delay_ms(500);<br /><br />             for( a=0; a&lt;2; a++){<br />                for( i=0; i&lt;15; i++){<br /><br />                  PORTD = tab1&#91; i &#93;;<br />                  _delay_ms(100);<br />                }<br />        }<br /><br />_delay_ms(500);<br /><br />    if(255 == jasnosc){<br />        for(jasnosc = 255; jasnosc&gt;0; jasnosc--){<br /><br />            OCR1A = jasnosc;<br />            OCR1B = jasnosc;<br />            _delay_ms(10);<br />            }<br />        }<br /><br />     for( a=0; a&lt;10; a++){<br />        for( i=0; i&lt;2; i++){<br /><br />        PORTD = tab2&#91; i &#93;;<br />        _delay_ms(50);<br />             }<br />          }<br /><br />     for( a=0; a&lt;1; a++){<br />            b=0;<br />        for( i=0; i&lt;25; i++){<br /><br />        OCR1A = b;<br />        OCR1B = b;<br />        PORTD = tab3&#91; i &#93;;<br />        _delay_ms(50);<br />        b = b+10;<br />             }<br />          }<br />PORTD = 0x00;<br /><br />     for( a=0; a&lt;20; a++){<br />        for( i=0; i&lt;3; i++){<br /><br />        OCR1A = tab_pwm_A_1&#91; i &#93;;<br />        OCR1B = tab_pwm_B_1&#91; i &#93;;<br />        _delay_ms(100);<br />             }<br />          }<br /><br />     for( a=0; a&lt;3; a++){<br />        for( i=0; i&lt;27; i++){<br /><br />        PORTD = tab4&#91; i &#93;;<br />        _delay_ms(100);<br />             }<br />          }<br /><br />       }<br />    }[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4734">sebbek</a> — 20 gru 2014, o 13:31</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Marcin_G]]></name></author>
<updated>2014-12-20T13:24:27+01:00</updated>
<published>2014-12-20T13:24:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109637#p109637</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109637#p109637"/>
<title type="html"><![CDATA[Re: Problem z PWM-em]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109637#p109637"><![CDATA[
Musisz  skonfigurować TIMER w taki sam sposób, w jaki to zrobiłeś konfigurując go do pracy na OCR0A. Skoro chcesz więc włączyć PWM na OCR0B powinieneś zrobić to na przykład w ten sposób: TCCR0A |= (1&lt;&lt;COM0B1); Nie wiem jakiego używasz procesora, więc mogłem popełnić błąd w rejestrach.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=758">Marcin_G</a> — 20 gru 2014, o 13:24</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[sebbek]]></name></author>
<updated>2014-12-20T10:40:36+01:00</updated>
<published>2014-12-20T10:40:36+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109616#p109616</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109616#p109616"/>
<title type="html"><![CDATA[Problem z PWM-em]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=9773&amp;p=109616#p109616"><![CDATA[
Witam, napisałem sobie taki program do PWM-a na OC0A:<br /><br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br /><br /><br />void pwm_init() // inicjalizacja PWM<br />{<br /><br />   TCCR0A |= (1&lt;&lt;WGM01)|(1&lt;&lt;COM0A1)|(1&lt;&lt;WGM00); // timer0<br />   TCCR0B |= (1&lt;&lt;CS00);<br /><br />   DDRB |=(1&lt;&lt;PB2);<br /><br />}<br /><br />int main(void)<br />{<br />   pwm_init();<br />   uint8_t jasnosc = 0;<br /><br />   while(1){<br /><br />    if(0 == jasnosc){<br />        for(jasnosc = 0; jasnosc&lt;255; jasnosc++){<br /><br />            OCR0A = jasnosc;<br />            _delay_ms(10);<br />            }<br />        }<br /><br />_delay_ms(500);<br /><br />    if(255 == jasnosc){<br />        for(jasnosc = 255; jasnosc&gt;0; jasnosc--){<br /><br />            OCR0A = jasnosc;<br />            _delay_ms(10);<br />            }<br />        }<br />    }<br />}[/syntax]<br /><br />i na PB2 działa ładnie ale jak próbuje zrobić to samo na PB3 (OC1A) lub PD5 (OC0B) to ta druga dioda ciągle świeci. Chciałbym uruchomić 2 niezależne PWM-y ale nie wiem jak <img src="https://forum.atnel.pl/images/smilies/icon_e_sad.gif" alt=":(" title="Smutny" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=4734">sebbek</a> — 20 gru 2014, o 10:40</p><hr />
]]></content>
</entry>
</feed>