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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2016-11-04T10:22:09+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=16662&amp;mode</id>
<entry>
<author><name><![CDATA[andrews]]></name></author>
<updated>2016-11-04T10:22:09+01:00</updated>
<published>2016-11-04T10:22:09+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173687#p173687</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173687#p173687"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173687#p173687"><![CDATA[
Na temat Bascoma nie wypowiem się, bo go nie znam. Natomiast nawet pisząc w języku C, kod wynikowy w dużej mierze jest zależny od ustawionego poziomu optymalizacji (jak zresztą również wcześniej pokazał kolega <strong>krish</strong>).<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=14165">andrews</a> — 4 lis 2016, o 10:22</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-11-04T09:57:34+01:00</updated>
<published>2016-11-04T09:57:34+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173685#p173685</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173685#p173685"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173685#p173685"><![CDATA[
Ehh asembler... wstyd się przyznać ale to dla mnie czarna magia ;( chyba jednak trzeba będzie zaczerpnąć jakiejś lekcji chociaż podstaw. Czyli rozumiem ze te opóźnienia wynikają z poziomu programowania? Jak bym napisał taki sam program powiedzmy w bascomie to opóźnienia byłyby jeszcze większe?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 4 lis 2016, o 09:57</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[micky]]></name></author>
<updated>2016-11-04T08:03:01+01:00</updated>
<published>2016-11-04T08:03:01+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173680#p173680</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173680#p173680"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173680#p173680"><![CDATA[
Kup sobie Saleae na portalu aucyjnym (koszt poniżej 50zl). Przyda ci się do tego (sprawdzisz dokladnie czasy przełączania itd.) i do wielu innych rzeczy. Ew.  możesz spróbować zmierzyć częstotliwość miernikiem.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1546">micky</a> — 4 lis 2016, o 08:03</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[andrews]]></name></author>
<updated>2016-11-04T07:40:34+01:00</updated>
<published>2016-11-04T07:40:34+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173676#p173676</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173676#p173676"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173676#p173676"><![CDATA[
<div class="quotetitle">klimeq napisał(a):</div><div class="quotecontent"><br />Dziwi mnie dlaczego bez żadnych delay'ów jest tak mała częstotliwość.<br /></div><br />Załóżmy, że masz ustawioną częstotliwość taktowania mikrokontrolera 1MHz.<br />Jak już wcześniej pokazał Tobie kolega <strong>krish</strong> jeden obieg pętli <strong>while</strong>, czyli jeden okres generowanego przebiegu, to 3 instrukcje asemblera, z których każda trwa 2 takty zegara, łącznie 6 taktów.<br />Jeżeli teraz podzielisz 1MHz przez 6, to jaką częstotliwość uzyskasz?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=14165">andrews</a> — 4 lis 2016, o 07:40</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[majster]]></name></author>
<updated>2016-11-04T00:20:21+01:00</updated>
<published>2016-11-04T00:20:21+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173664#p173664</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173664#p173664"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173664#p173664"><![CDATA[
Ale jak?<br /><br />Sorry ale twoje pytanie to już wyższa szkoła wróżenia nie ze szklanej kuli ale to jest jak wróżenie z piasku.<br /><br />Wysłane z mojego LIVE przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1628">majster</a> — 4 lis 2016, o 00:20</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[tomas140]]></name></author>
<updated>2016-11-03T23:51:06+01:00</updated>
<published>2016-11-03T23:51:06+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173663#p173663</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173663#p173663"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173663#p173663"><![CDATA[
Problemem okazał się jeden Warning którego olałem na początku <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /> Jednak zastanawia mnie ta częstotliwość zmiany stanu pinu bez opóźnień. Czy mógłby mi ktoś z Was wytłumaczyć dla czego tak jest ? <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=10605">tomas140</a> — 3 lis 2016, o 23:51</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-31T09:45:05+01:00</updated>
<published>2016-10-31T09:45:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173262#p173262</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173262#p173262"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173262#p173262"><![CDATA[
Dziwi mnie dlaczego bez żadnych delay'ów jest tak mała częstotliwość. Czy może to być spowodowane ustawieniami kompilatora ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 31 paź 2016, o 09:45</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T20:52:58+01:00</updated>
<published>2016-10-30T20:52:58+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173235#p173235</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173235#p173235"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173235#p173235"><![CDATA[
Jeden projekt zmieniam kod i ewentualnie zegar. Optymalizacja Os<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 20:52</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[krish]]></name></author>
<updated>2016-10-30T20:47:14+01:00</updated>
<published>2016-10-30T20:47:14+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173232#p173232</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173232#p173232"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173232#p173232"><![CDATA[
Zobacz w pliku *.lss lub *.lst  w projekcie- jak to się skompilowało.<br />[syntax=asm]int main(void)<br />{<br />    DDRC |= (1&lt;&lt;PC0);<br />  6c:a0 9a       sbi0x14, 0; 20<br />        while(1)<br />        {<br />            PORTC |= (1&lt;&lt;PC0);<br />  6e:a8 9a       sbi0x15, 0; 21<br />                    PORTC &amp;=~(1&lt;&lt;PC0);<br />  70:a8 98       cbi0x15, 0; 21<br />}<br />  72:fd cf       rjmp.-6      ; 0x6e &lt;main+0x2&gt;[/syntax]<br />Wychodzi chyba nawet więcej sbi/cbi/rjmp po 2 takty zagara<br /><br />Czy Twoje przykłady były kompilowane w różnych projektach czy w jednym poprzez podmianę kodu? Czy włączona optymalizacja?<br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 2 minutach ]</span></strong><br /><br />To samo bez opymalizacji<br />[syntax=asm]int main(void)<br />{<br />    DDRC |= (1&lt;&lt;PC0);<br />  6c:84 e3       ldir24, 0x34; 52<br />  6e:90 e0       ldir25, 0x00; 0<br />  70:24 e3       ldir18, 0x34; 52<br />  72:30 e0       ldir19, 0x00; 0<br />  74:f9 01       movwr30, r18<br />  76:20 81       ldr18, Z<br />  78:21 60       orir18, 0x01; 1<br />  7a:fc 01       movwr30, r24<br />  7c:20 83       stZ, r18<br />        while(1)<br />        {<br />            PORTC |= (1&lt;&lt;PC0);<br />  7e:85 e3       ldir24, 0x35; 53<br />  80:90 e0       ldir25, 0x00; 0<br />  82:25 e3       ldir18, 0x35; 53<br />  84:30 e0       ldir19, 0x00; 0<br />  86:f9 01       movwr30, r18<br />  88:20 81       ldr18, Z<br />  8a:21 60       orir18, 0x01; 1<br />  8c:fc 01       movwr30, r24<br />  8e:20 83       stZ, r18<br />                    PORTC &amp;=~(1&lt;&lt;PC0);<br />  90:85 e3       ldir24, 0x35; 53<br />  92:90 e0       ldir25, 0x00; 0<br />  94:25 e3       ldir18, 0x35; 53<br />  96:30 e0       ldir19, 0x00; 0<br />  98:f9 01       movwr30, r18<br />  9a:20 81       ldr18, Z<br />  9c:2e 7f       andir18, 0xFE; 254<br />  9e:fc 01       movwr30, r24<br />  a0:20 83       stZ, r18<br />}<br />  a2:ed cf       rjmp.-38     ; 0x7e &lt;main+0x12&gt;[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2273">krish</a> — 30 paź 2016, o 20:47</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[adamBo]]></name></author>
<updated>2016-10-30T20:29:46+01:00</updated>
<published>2016-10-30T20:29:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173227#p173227</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173227#p173227"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173227#p173227"><![CDATA[
Kod2: powinno być ok 1 MHz<br /><br />Wysłane z mojego HTC One_M8 przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9051">adamBo</a> — 30 paź 2016, o 20:29</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T20:21:03+01:00</updated>
<published>2016-10-30T20:21:03+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173223#p173223</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173223#p173223"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173223#p173223"><![CDATA[
[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br />int main(void)<br />{<br /><br />DDRC |= (1&lt;&lt;PC0);<br />    while(1)<br />    {<br />        PORTC |= (1&lt;&lt;PC0);<br />_delay_ms(1000);<br />PORTC &amp;=~(1&lt;&lt;PC0);<br />_delay_ms(1000);<br /><br />    }<br />}[/syntax]<br />pin przełącza idealnie co sekundę, natomiast <br /><br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;util/delay.h&gt;<br />int main(void)<br />{<br /><br />DDRC |= (1&lt;&lt;PC0);<br />    while(1)<br />    {<br />        PORTC |= (1&lt;&lt;PC0);<br />PORTC &amp;=~(1&lt;&lt;PC0);<br />    }<br />}[/syntax]<br /><br />daje mi szpilki 165.5kHz a powinno być 1MHz tak ? czy może się mylę ?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 20:21</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[krish]]></name></author>
<updated>2016-10-30T20:12:01+01:00</updated>
<published>2016-10-30T20:12:01+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173220#p173220</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173220#p173220"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173220#p173220"><![CDATA[
Napisz najprostszy program przełączający jakimś pinem ( lub LED-em) za pomocą <br />funkcji _delay_ms(1000), oczywiście przy właściwych ustawieniach F_CPU (analiza wyników z kompilacji) ,  i sprawdź czy pin przełącza/mruga co sekundę- będziesz wtedy wiedział, że procesor (fusy) i kompilator są dobrze ustawione. Wtedy pozostanie analiza/zmiana programu obs ługi KS-a. Możliwe, choć mało prawdopodobne, że źle działa kwarc/oscylator i wzbudza się na innej częstotliwości. Kondensatory przy kwarcu?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2273">krish</a> — 30 paź 2016, o 20:12</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[adamBo]]></name></author>
<updated>2016-10-30T20:10:48+01:00</updated>
<published>2016-10-30T20:10:48+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173219#p173219</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173219#p173219"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173219#p173219"><![CDATA[
Tak powinieneś mieć 16MHz<br /><br />Wysłane z mojego HTC One_M8 przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9051">adamBo</a> — 30 paź 2016, o 20:10</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T20:10:26+01:00</updated>
<published>2016-10-30T20:10:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173218#p173218</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173218#p173218"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173218#p173218"><![CDATA[
Od 1 do 8 Mhz na wewnętrznym oscylatorze a 16 podpinam kwarc. <br />Warning2      inline function 'ks0108ReadData' declared but never defined [enabled by default]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 20:10</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Harry]]></name></author>
<updated>2016-10-30T20:04:47+01:00</updated>
<published>2016-10-30T20:04:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173217#p173217</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173217#p173217"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173217#p173217"><![CDATA[
Masz jakieś warningi przy kompilacji?<br />Piszesz że reaguje na zmianę częstotliwości, zmieniasz kwarce czy tylko w ustawieniach procka?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=14685">Harry</a> — 30 paź 2016, o 20:04</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T19:55:46+01:00</updated>
<published>2016-10-30T19:55:46+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173216#p173216</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173216#p173216"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173216#p173216"><![CDATA[
Sprawdzałem wszystkie możliwe opcje zegara  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br /><br />Dobra, powiedzcie mi bo ja już mam mętlik w głowie od tego wszystkiego. <br />Czy przy zegarze 16Mhz na pinie C0 powinienem mieć szpilki o częstotliwości ok. 16 Mhz ? <br />[syntax=c]#include &lt;avr/io.h&gt;<br />int main(void)<br />{<br /><br />DDRC |= (1&lt;&lt;PC0);<br />    while(1)<br />    {<br />        PORTC |= (1&lt;&lt;PC0);<br />PORTC &amp;=~(1&lt;&lt;PC0);<br />    }<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 19:55</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[adamBo]]></name></author>
<updated>2016-10-30T19:53:53+01:00</updated>
<published>2016-10-30T19:53:53+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173215#p173215</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173215#p173215"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173215#p173215"><![CDATA[
W akcie desperacji jak się wyraziłeś dałeś mu pałą w łeb by się zamulał tym 1MHz. Weź sobie na spokojnie posprawdzaj ustawienia zegara a jak już będziesz zdesperowany to daj mu kopa w żyć to wtedy pewnie przyspieszy <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br /><br />Wysłane z mojego HTC One_M8 przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9051">adamBo</a> — 30 paź 2016, o 19:53</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[krish]]></name></author>
<updated>2016-10-30T19:53:10+01:00</updated>
<published>2016-10-30T19:53:10+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173214#p173214</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173214#p173214"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173214#p173214"><![CDATA[
W Studio też ustawia się F_CPU w opcjach projektu- poszukaj w sieci.<br />ps.<br />Ty programujesz w &quot;C&quot;, a Eclipse i AS to tylko tzw. IDE trochę &quot;inteligentniejsze&quot;  edytory tekstu i &quot;uruchamiacze&quot; kompilacji i ew. programatorów.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2273">krish</a> — 30 paź 2016, o 19:53</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T19:45:57+01:00</updated>
<published>2016-10-30T19:45:57+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173213#p173213</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173213#p173213"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173213#p173213"><![CDATA[
Wyświetlanie reaguje na zmianę częstotliwości (im wyższa tym szybciej wyświetla) na filmiku jest 16Mhz. F_CPU użyłem w akcie desperacji  <img src="https://forum.atnel.pl/images/smilies/icon_e_biggrin.gif" alt=":D" title="Bardzo szczęśliwy" /> . Ja programuje w AS 6 nie ECLIPSE  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br /><br /><strong><span style="color: #808000">------------------------ [ Dodano po: 6 minutach ]</span></strong><br /><br /><div class="quotetitle">krish napisał(a):</div><div class="quotecontent"><br />Jeżeli chcesz mieć naprawdę szybką obsługę KS-a, znajdź/napisz jego obsługę za pomocą bufora w SRAM procesora. Zajmie to 1KB (128*64/8 ), w mniejszych projektach nie powinno przeszkadzać.<br /></div><br /><br /><br />krish ja rozumiem że to nie jest najszybszy sposób na obsługę tego wyświetlacza ale nie rozumiem czemu ten sam kod wczoraj działał poprawnie a dzisiaj tak zamula  <img src="https://forum.atnel.pl/images/smilies/icon_eek.gif" alt=":shock:" title="Zaszokowany" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 19:45</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[krish]]></name></author>
<updated>2016-10-30T19:45:08+01:00</updated>
<published>2016-10-30T19:45:08+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173212#p173212</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173212#p173212"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173212#p173212"><![CDATA[
Jeżeli chcesz mieć naprawdę szybką obsługę KS-a, znajdź/napisz jego obsługę za pomocą bufora w SRAM procesora. Zajmie to 1KB (128*64/8 ), w mniejszych projektach nie powinno przeszkadzać.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2273">krish</a> — 30 paź 2016, o 19:45</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Harry]]></name></author>
<updated>2016-10-30T19:43:59+01:00</updated>
<published>2016-10-30T19:43:59+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173211#p173211</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173211#p173211"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173211#p173211"><![CDATA[
<div class="quotetitle">klimeq napisał(a):</div><div class="quotecontent"><br />#define F_CPU 1000000<br /></div><br />A co to robi w kodzie?<br />Naprawdę odpalasz to na 1MHz?<br /><br />widzę że kolega wyżej mnie uprzedził <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=14685">Harry</a> — 30 paź 2016, o 19:43</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[adamBo]]></name></author>
<updated>2016-10-30T19:38:21+01:00</updated>
<published>2016-10-30T19:38:21+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173210#p173210</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173210#p173210"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173210#p173210"><![CDATA[
Wywal kolego definicje f-CPU to robimy z poziomu ustawień w eklipsie. Zobacz jak przedstawisz fuzy na 8MHz czy wyświetlacz przyspieszy .<br /><br />Wysłane z mojego HTC One_M8 przy użyciu Tapatalka<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=9051">adamBo</a> — 30 paź 2016, o 19:38</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[michal1210]]></name></author>
<updated>2016-10-30T19:17:35+01:00</updated>
<published>2016-10-30T19:17:35+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173209#p173209</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173209#p173209"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173209#p173209"><![CDATA[
kolego popraw wstawianie kodu bo zaraz moderatorzy się przyczepią...<br /><br />Jesteś z nami już prawie rok i pewnie nie jeden wątek przeczytałeś i nie raz już były podobne sytuacje, że pytanie nie było sprecyzowane albo źle wstawiony kod. Na pewno się na takie coś natknąłeś nie raz, więc nie popełniaj takich podstawowych błędów <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=998">michal1210</a> — 30 paź 2016, o 19:17</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[klimeq]]></name></author>
<updated>2016-10-30T19:34:01+01:00</updated>
<published>2016-10-30T19:12:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173206#p173206</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173206#p173206"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173206#p173206"><![CDATA[
ks108.c<br />[syntax=c]#include &lt;inttypes.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &quot;ks0108.h&quot;<br /><br />lcdCoordks0108Coord;<br />uint8_tks0108Inverted=0;<br />ks0108FontCallbackks0108FontRead;<br />uint8_tks0108FontColor;<br />const uint8_t*ks0108Font;<br /><br />void ks0108DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color) {<br />uint8_t length, i, y, yAlt, xTmp, yTmp;<br />int16_t m;<br /><br />//<br />// vertical line<br />//<br />if(x1 == x2) {<br />// x1|y1 must be the upper point<br />if(y1 &gt; y2) {<br />yTmp = y1;<br />y1 = y2;<br />y2 = yTmp;<br />}<br />ks0108DrawVertLine(x1, y1, y2-y1, color);<br /><br />//<br />// horizontal line<br />//<br />} else if(y1 == y2) {<br />// x1|y1 must be the left point<br />if(x1 &gt; x2) {<br />xTmp = x1;<br />x1 = x2;<br />x2 = xTmp;<br />}<br />ks0108DrawHoriLine(x1, y1, x2-x1, color);<br /><br />//<br />// schiefe line :)<br />//<br />} else {<br />// angle &gt;= 45°<br />if((y2-y1) &gt;= (x2-x1) || (y1-y2) &gt;= (x2-x1)) {<br />// x1 must be smaller than x2<br />if(x1 &gt; x2) {<br />xTmp = x1;<br />yTmp = y1;<br />x1 = x2;<br />y1 = y2;<br />x2 = xTmp;<br />y2 = yTmp;<br />}<br /><br />length = x2-x1;// not really the length :)<br />m = ((y2-y1)*200)/length;<br />yAlt = y1;<br /><br />for(i=0; i&lt;=length; i++) {<br />y = ((m*i)/200)+y1;<br /><br />if((m*i)%200 &gt;= 100)<br />y++;<br />else if((m*i)%200 &lt;= -100)<br />y--;<br /><br />ks0108DrawLine(x1+i, yAlt, x1+i, y, color);<br /><br />if(length &lt;= (y2-y1) &amp;&amp; y1 &lt; y2)<br />yAlt = y+1;<br />else if(length &lt;= (y1-y2) &amp;&amp; y1 &gt; y2)<br />yAlt = y-1;<br />else<br />yAlt = y;<br />}<br /><br />// angle &lt; 45°<br />} else {<br />// y1 must be smaller than y2<br />if(y1 &gt; y2) {<br />xTmp = x1;<br />yTmp = y1;<br />x1 = x2;<br />y1 = y2;<br />x2 = xTmp;<br />y2 = yTmp;<br />}<br /><br />length = y2-y1;<br />m = ((x2-x1)*200)/length;<br />yAlt = x1;<br /><br />for(i=0; i&lt;=length; i++) {<br />y = ((m*i)/200)+x1;<br /><br />if((m*i)%200 &gt;= 100)<br />y++;<br />else if((m*i)%200 &lt;= -100)<br />y--;<br /><br />ks0108DrawLine(yAlt, y1+i, y, y1+i, color);<br />if(length &lt;= (x2-x1) &amp;&amp; x1 &lt; x2)<br />yAlt = y+1;<br />else if(length &lt;= (x1-x2) &amp;&amp; x1 &gt; x2)<br />yAlt = y-1;<br />else<br />yAlt = y;<br />}<br />}<br />}<br />}<br /><br />void ks0108DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) {<br />ks0108DrawHoriLine(x, y, width, color);// top<br />ks0108DrawHoriLine(x, y+height, width, color);// bottom<br />ks0108DrawVertLine(x, y, height, color);// left<br />ks0108DrawVertLine(x+width, y, height, color);// right<br />}<br /><br />void ks0108DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color) {<br />  int16_t tSwitch, x1 = 0, y1 = radius;<br />  tSwitch = 3 - 2 * radius;<br /><br />while (x1 &lt;= y1) {<br />    ks0108SetDot(x+radius - x1, y+radius - y1, color);<br />    ks0108SetDot(x+radius - y1, y+radius - x1, color);<br /><br />    ks0108SetDot(x+width-radius + x1, y+radius - y1, color);<br />    ks0108SetDot(x+width-radius + y1, y+radius - x1, color);<br />    <br />    ks0108SetDot(x+width-radius + x1, y+height-radius + y1, color);<br />    ks0108SetDot(x+width-radius + y1, y+height-radius + x1, color);<br /><br />    ks0108SetDot(x+radius - x1, y+height-radius + y1, color);<br />    ks0108SetDot(x+radius - y1, y+height-radius + x1, color);<br /><br />    if (tSwitch &lt; 0) {<br />    tSwitch += (4 * x1 + 6);<br />    } else {<br />    tSwitch += (4 * (x1 - y1) + 10);<br />    y1--;<br />    }<br />    x1++;<br />}<br />  <br />ks0108DrawHoriLine(x+radius, y, width-(2*radius), color);// top<br />ks0108DrawHoriLine(x+radius, y+height, width-(2*radius), color);// bottom<br />ks0108DrawVertLine(x, y+radius, height-(2*radius), color);// left<br />ks0108DrawVertLine(x+width, y+radius, height-(2*radius), color);// right<br />}<br /><br />/*<br /> * Hardware-Functions <br /> */<br />void ks0108FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color) {<br />uint8_t mask, pageOffset, h, i, data;<br />height++;<br /><br />pageOffset = y%8;<br />y -= pageOffset;<br />mask = 0xFF;<br />if(height &lt; 8-pageOffset) {<br />mask &gt;&gt;= (8-height);<br />h = height;<br />} else {<br />h = 8-pageOffset;<br />}<br />mask &lt;&lt;= pageOffset;<br /><br />ks0108GotoXY(x, y);<br />for(i=0; i&lt;=width; i++) {<br />data = ks0108ReadData();<br /><br />if(color == BLACK) {<br />data |= mask;<br />} else {<br />data &amp;= ~mask;<br />}<br /><br />ks0108WriteData(data);<br />}<br /><br />while(h+8 &lt;= height) {<br />h += 8;<br />y += 8;<br />ks0108GotoXY(x, y);<br /><br />for(i=0; i&lt;=width; i++) {<br />ks0108WriteData(color);<br />}<br />}<br /><br />if(h &lt; height) {<br />mask = ~(0xFF &lt;&lt; (height-h));<br />ks0108GotoXY(x, y+8);<br /><br />for(i=0; i&lt;=width; i++) {<br />data = ks0108ReadData();<br /><br />if(color == BLACK) {<br />data |= mask;<br />} else {<br />data &amp;= ~mask;<br />}<br /><br />ks0108WriteData(data);<br />}<br />}<br />}<br /><br />void ks0108InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height) {<br />uint8_t mask, pageOffset, h, i, data, tmpData;<br />height++;<br /><br />pageOffset = y%8;<br />y -= pageOffset;<br />mask = 0xFF;<br />if(height &lt; 8-pageOffset) {<br />mask &gt;&gt;= (8-height);<br />h = height;<br />} else {<br />h = 8-pageOffset;<br />}<br />mask &lt;&lt;= pageOffset;<br /><br />ks0108GotoXY(x, y);<br />for(i=0; i&lt;=width; i++) {<br />data = ks0108ReadData();<br />tmpData = ~data;<br />data = (tmpData &amp; mask) | (data &amp; ~mask);<br />ks0108WriteData(data);<br />}<br /><br />while(h+8 &lt;= height) {<br />h += 8;<br />y += 8;<br />ks0108GotoXY(x, y);<br /><br />for(i=0; i&lt;=width; i++) {<br />data = ks0108ReadData();<br />ks0108WriteData(~data);<br />}<br />}<br /><br />if(h &lt; height) {<br />mask = ~(0xFF &lt;&lt; (height-h));<br />ks0108GotoXY(x, y+8);<br /><br />for(i=0; i&lt;=width; i++) {<br />data = ks0108ReadData();<br />tmpData = ~data;<br />data = (tmpData &amp; mask) | (data &amp; ~mask);<br />ks0108WriteData(data);<br />}<br />}<br />}<br /><br />void ks0108SetInverted(uint8_t invert) {<br />if(ks0108Inverted != invert) {<br />ks0108InvertRect(0,0,127,63);<br />ks0108Inverted = invert;<br />}<br />}<br /><br />void ks0108SetDot(uint8_t x, uint8_t y, uint8_t color) {<br />uint8_t data;<br /><br />ks0108GotoXY(x, y-y%8);// read data from display memory<br />data = ks0108ReadData();<br /><br />if(color == BLACK) {<br />data |= 0x01 &lt;&lt; (y%8);// set dot<br />} else {<br />data &amp;= ~(0x01 &lt;&lt; (y%8));// clear dot<br />}<br /><br />ks0108WriteData(data);// write data back to display<br />}<br /><br />//<br />// Font Functions<br />//<br /><br />uint8_t ks0108ReadFontData(const uint8_t* ptr) {<br />return pgm_read_byte(ptr);<br />}<br /><br />void ks0108SelectFont(const char* font, ks0108FontCallback callback, uint8_t color) {<br />ks0108Font = font;<br />ks0108FontRead = callback;<br />ks0108FontColor = color;<br />}<br /><br />int ks0108PutChar(char c) {<br />uint8_t width = 0;<br />uint8_t height = ks0108FontRead(ks0108Font+FONT_HEIGHT);<br />uint8_t bytes = (height+7)/8;<br /><br />uint8_t firstChar = ks0108FontRead(ks0108Font+FONT_FIRST_CHAR);<br />uint8_t charCount = ks0108FontRead(ks0108Font+FONT_CHAR_COUNT);<br /><br />uint16_t index = 0;<br />uint8_t x = ks0108Coord.x, y = ks0108Coord.y;<br /><br />if(c &lt; firstChar || c &gt;= (firstChar+charCount)) {<br />return 1;<br />}<br />c-= firstChar;<br /><br />// read width data, to get the index<br />for(uint8_t i=0; i&lt;c; i++) {<br />index += ks0108FontRead(ks0108Font+FONT_WIDTH_TABLE+i);<br />}<br />index = index*bytes+charCount+FONT_WIDTH_TABLE;<br />width = ks0108FontRead(ks0108Font+FONT_WIDTH_TABLE+c);<br /><br />// last but not least, draw the character<br />for(uint8_t i=0; i&lt;bytes; i++) {<br />uint8_t page = i*width;<br />for(uint8_t j=0; j&lt;width; j++) {<br />uint8_t data = ks0108FontRead(ks0108Font+index+page+j);<br /><br />if(height &lt; (i+1)*8) {<br />data &gt;&gt;= (i+1)*8-height;<br />}<br /><br />if(ks0108FontColor == BLACK) {<br />ks0108WriteData(data);<br />} else {<br />ks0108WriteData(~data);<br />}<br />}<br />// 1px gap between chars<br />if(ks0108FontColor == BLACK) {<br />ks0108WriteData(0x00);<br />} else {<br />ks0108WriteData(0xFF);<br />}<br />ks0108GotoXY(x, ks0108Coord.y+8);<br />}<br />ks0108GotoXY(x+width+1, y);<br /><br />return 0;<br />}<br /><br />void ks0108Puts(char* str) {<br />int x = ks0108Coord.x;<br />while(*str != 0) {<br />if(*str == '\n') {<br />ks0108GotoXY(x, ks0108Coord.y+ks0108FontRead(ks0108Font+FONT_HEIGHT));<br />} else {<br />ks0108PutChar(*str);<br />}<br />str++;<br />}<br />}<br /><br />void ks0108Puts_P(PGM_P str) {<br />int x = ks0108Coord.x;<br />while(pgm_read_byte(str) != 0) {<br />if(pgm_read_byte(str) == '\n') {<br />ks0108GotoXY(x, ks0108Coord.y+ks0108FontRead(ks0108Font+FONT_HEIGHT));<br />} else {<br />ks0108PutChar(pgm_read_byte(str));<br />}<br />str++;<br />}<br />}<br /><br />uint8_t ks0108CharWidth(char c) {<br />uint8_t width = 0;<br />uint8_t firstChar = ks0108FontRead(ks0108Font+FONT_FIRST_CHAR);<br />uint8_t charCount = ks0108FontRead(ks0108Font+FONT_CHAR_COUNT);<br /><br />// read width data<br />if(c &gt;= firstChar &amp;&amp; c &lt; (firstChar+charCount)) {<br />c -= firstChar;<br />width = ks0108FontRead(ks0108Font+FONT_WIDTH_TABLE+c)+1;<br />}<br /><br />return width;<br />}<br /><br />uint16_t ks0108StringWidth(char* str) {<br />uint16_t width = 0;<br /><br />while(*str != 0) {<br />width += ks0108CharWidth(*str++);<br />}<br /><br />return width;<br />}<br /><br />uint16_t ks0108StringWidth_P(PGM_P str) {<br />uint16_t width = 0;<br /><br />while(pgm_read_byte(str) != 0) {<br />width += ks0108CharWidth(pgm_read_byte(str++));<br />}<br /><br />return width;<br />}<br /><br />void ks0108GotoXY(uint8_t x, uint8_t y) {<br />uint8_t chip = CHIP1, cmd;<br /><br />if(x &gt; 127) x = 0;// ensure that coordinates are legal<br />if(y &gt; 63)  y = 0;<br /><br />ks0108Coord.x = x;// save new coordinates<br />ks0108Coord.y = y;<br />ks0108Coord.page = y/8;<br /><br />if(x &gt;= 64) {// select the right chip<br />x -= 64;<br />chip = CHIP2;<br />}<br />cmd = LCD_SET_ADD | x;<br />ks0108WriteCommand(cmd, chip);// set x address on active chip<br /><br />cmd = LCD_SET_PAGE | ks0108Coord.page;// set y address on both chips<br />ks0108WriteCommand(cmd, CHIP1);<br />ks0108WriteCommand(cmd, CHIP2);<br />}<br /><br />void ks0108Init(uint8_t invert) {<br />ks0108Coord.x = 0;<br />ks0108Coord.y = 0;<br />ks0108Coord.page = 0;<br /><br />ks0108Inverted = invert;<br /><br />LCD_CMD_DIR = 0xFF;// command port is output<br />ks0108WriteCommand(LCD_ON, CHIP1);// power on<br />ks0108WriteCommand(LCD_ON, CHIP2);<br /><br />ks0108WriteCommand(LCD_DISP_START, CHIP1);// display start line = 0<br />ks0108WriteCommand(LCD_DISP_START, CHIP2);<br />ks0108ClearScreen();// display clear<br />ks0108GotoXY(0,0);<br />}<br /><br />inline void ks0108Enable(void) {<br />LCD_CMD_PORT |= 0x01 &lt;&lt; EN;// EN high level width: min. 450ns<br />asm volatile(&quot;nop\n\t&quot;<br /> &quot;nop\n\t&quot;<br /> &quot;nop\n\t&quot;<br /> ::);<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; EN);<br />for(volatile uint8_t i=0; i&lt;8; i++);// a little delay loop (faster than reading the busy flag)<br />}<br /><br />uint8_t ks0108DoReadData(uint8_t first) {<br />uint8_t data;<br />volatile uint8_t i;<br /><br />LCD_DATA_OUT = 0x00;<br />LCD_DATA_DIR = 0x00;// data port is input<br /><br />if(ks0108Coord.x &lt; 64) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL2);// deselect chip 2<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL1;// select chip 1<br />} else if(ks0108Coord.x &gt;= 64) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL1);// deselect chip 1<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL2;// select chip 2<br />}<br />if(ks0108Coord.x == 64 &amp;&amp; first) {// chip2 X-address = 0<br />ks0108WriteCommand(LCD_SET_ADD, CHIP2); // wuff wuff<br />}<br /><br />LCD_CMD_PORT |= 0x01 &lt;&lt; D_I;// D/I = 1<br />LCD_CMD_PORT |= 0x01 &lt;&lt; R_W;// R/W = 1<br /><br />LCD_CMD_PORT |= 0x01 &lt;&lt; EN;// EN high level width: min. 450ns<br />asm volatile(&quot;nop\n\t&quot;<br /> &quot;nop\n\t&quot;<br /> &quot;nop\n\t&quot;<br /> ::);<br /><br />data = LCD_DATA_IN;// read Data <br /><br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; EN);<br />for(i=0; i&lt;8; i++);// a little delay loop (faster than reading the busy flag)<br /><br />LCD_DATA_DIR = 0xFF;<br /><br />ks0108GotoXY(ks0108Coord.x, ks0108Coord.y);<br /><br />if(ks0108Inverted)<br />data = ~data;<br />return data;<br />}<br /><br />inline uint8_t ks0108ReadData(void) {<br />ks0108DoReadData(1);// dummy read<br />return ks0108DoReadData(0);// &quot;real&quot; read<br />}<br /><br />void ks0108WriteCommand(uint8_t cmd, uint8_t chip) {<br />if(chip == CHIP1) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL2);// deselect chip 2<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL1;// select chip 1<br />} else if(chip == CHIP2) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL1);// deselect chip 1<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL2;// select chip 2<br />}<br /><br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; D_I);// D/I = 0<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; R_W);// R/W = 0<br />LCD_DATA_DIR = 0xFF;// data port is output<br />LCD_DATA_OUT = cmd;// write command<br />ks0108Enable();// enable<br />LCD_DATA_OUT = 0x00;<br />}<br /><br />void ks0108WriteData(uint8_t data) {<br />uint8_t displayData, yOffset, cmdPort;<br /><br />#ifdef DEBUG<br />volatile uint16_t i;<br />for(i=0; i&lt;5000; i++);<br />#endif<br /><br />if(ks0108Coord.x &gt;= 128)<br />return;<br /><br />if(ks0108Coord.x &lt; 64) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL2);// deselect chip 2<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL1;// select chip 1<br />} else if(ks0108Coord.x &gt;= 64) {<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; CSEL1);// deselect chip 1<br />LCD_CMD_PORT |= 0x01 &lt;&lt; CSEL2;// select chip 2<br />}<br />if(ks0108Coord.x == 64)// chip2 X-address = 0<br />ks0108WriteCommand(LCD_SET_ADD, CHIP2);<br /><br />LCD_CMD_PORT |= 0x01 &lt;&lt; D_I;// D/I = 1<br />LCD_CMD_PORT &amp;= ~(0x01 &lt;&lt; R_W);// R/W = 0<br />LCD_DATA_DIR = 0xFF;// data port is output<br /><br /><br />yOffset = ks0108Coord.y%8;<br />if(yOffset != 0) {<br />// first page<br />cmdPort = LCD_CMD_PORT;// save command port<br />displayData = ks0108ReadData();<br /><br />LCD_CMD_PORT = cmdPort;// restore command port<br />LCD_DATA_DIR = 0xFF;// data port is output<br /><br />displayData |= data &lt;&lt; yOffset;<br />if(ks0108Inverted)<br />displayData = ~displayData;<br />LCD_DATA_OUT = displayData;// write data<br />ks0108Enable();// enable<br /><br />// second page<br />ks0108GotoXY(ks0108Coord.x, ks0108Coord.y+8);<br /><br />displayData = ks0108ReadData();<br /><br />LCD_CMD_PORT = cmdPort;// restore command port<br />LCD_DATA_DIR = 0xFF;// data port is output<br /><br />displayData |= data &gt;&gt; (8-yOffset);<br />if(ks0108Inverted)<br />displayData = ~displayData;<br />LCD_DATA_OUT = displayData;// write data<br />ks0108Enable();// enable<br /><br />ks0108GotoXY(ks0108Coord.x+1, ks0108Coord.y-8);<br />} else {<br />if(ks0108Inverted)<br />data = ~data;<br />LCD_DATA_OUT = data;// write data<br />ks0108Enable();// enable<br />ks0108Coord.x++;<br />}<br />LCD_DATA_OUT = 0x00;<br />}[/syntax]<br /><br />ks108.h<br />[syntax=c]#include &lt;inttypes.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />#ifndefKS0108_H<br />#define KS0108_H<br /><br />// Ports<br />#define LCD_CMD_PORTPORTC// Command Output Register<br />#define LCD_CMD_DIRDDRC// Data Direction Register for Command Port<br /><br />#define LCD_DATA_INPINA// Data Input Register<br />#define LCD_DATA_OUTPORTA// Data Output Register<br />#define LCD_DATA_DIRDDRA// Data Direction Register for Data Port<br /><br />// Command Port Bits<br />#define D_IPC2// D/I Bit Number<br />#define R_WPC1// R/W Bit Number<br />#define ENPC0// EN Bit Number<br />#define CSEL1PC5// CS1 Bit Number<br />#define CSEL2PC6// CS2 Bit Number<br /><br />// Chips<br />#define CHIP10x00<br />#define CHIP20x01<br /><br />// Commands<br />#define LCD_ON0x3F<br />#define LCD_OFF0x3E<br />#define LCD_SET_ADD0x40<br />#define LCD_SET_PAGE0xB8<br />#define LCD_DISP_START0xC0<br /><br />// Colors<br />#define BLACK0xFF<br />#define WHITE0x00<br /><br />// Font Indices<br />#define FONT_LENGTH0<br />#define FONT_FIXED_WIDTH2<br />#define FONT_HEIGHT8<br />#define FONT_FIRST_CHAR4<br />#define FONT_CHAR_COUNT5<br />#define FONT_WIDTH_TABLE6<br /><br />// Uncomment for slow drawing<br />// #define DEBUG<br /><br />typedef struct {<br />uint8_t x;<br />uint8_t y;<br />uint8_t page;<br />} lcdCoord;<br /><br />typedef uint8_t (*ks0108FontCallback)(const uint8_t*);<br /><br />//<br />// Function Prototypes<br />//<br /><br />// Graphic Functions<br />void ks0108DrawLine(uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint8_t color);<br />void ks0108DrawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);<br />void ks0108DrawRoundRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t radius, uint8_t color);<br />void ks0108FillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint8_t color);<br />void ks0108InvertRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height);<br />void ks0108SetInverted(uint8_t invert);<br />void ks0108SetDot(uint8_t x, uint8_t y, uint8_t color);<br /><br />#define ks0108DrawVertLine(x, y, length, color) {ks0108FillRect(x, y, 0, length, color);}<br />#define ks0108DrawHoriLine(x, y, length, color) {ks0108FillRect(x, y, length, 0, color);}<br />#define ks0108DrawCircle(xCenter, yCenter, radius, color) {ks0108DrawRoundRect(xCenter-radius, yCenter-radius, 2*radius, 2*radius, radius, color);}<br />#define ks0108ClearScreen() {ks0108FillRect(0, 0, 127, 63, WHITE);}<br /><br />// Font Functions<br />uint8_t ks0108ReadFontData(const uint8_t* ptr);//Standard Read Callback<br />void ks0108SelectFont(const char* font, ks0108FontCallback callback, uint8_t color);<br />int ks0108PutChar(char c);<br />void ks0108Puts(char* str);<br />void ks0108Puts_P(PGM_P str);<br />uint8_t ks0108CharWidth(char c);<br />uint16_t ks0108StringWidth(char* str);<br />uint16_t ks0108StringWidth_P(PGM_P str);<br /><br />// Control Functions<br />void ks0108GotoXY(uint8_t x, uint8_t y);<br />void ks0108Init(uint8_t invert);<br />inline uint8_t ks0108ReadData(void);<br />void ks0108WriteCommand(uint8_t cmd, uint8_t chip);<br />void ks0108WriteData(uint8_t data);<br /><br />#endif[/syntax]<br />[syntax=c]main.c<br />&#91;code&#93;#define F_CPU 1000000<br />#include &lt;inttypes.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />#include &quot;ks0108.h&quot;<br />#include &quot;arial_bold_14.h&quot;<br />#include &quot;corsiva_12.h&quot;<br /><br />int main(void) {<br /><br />// Wait a little while the display starts up<br />for(volatile uint16_t i=0; i&lt;15000; i++);<br /><br />// Initialize the LCD<br />ks0108Init(0);<br /><br />// Select a font<br />ks0108SelectFont(Arial_Bold_14, ks0108ReadFontData, BLACK);<br />// Set a position<br />ks0108GotoXY(15,10);<br />// Print some text<br />ks0108Puts_P(PSTR(&quot;KS0108-Treiber&quot;));<br />// a nice little round rect<br />ks0108DrawRoundRect(5, 5, 117, 20, 8, BLACK);<br /><br />// Once again :)<br />// Select a font<br />ks0108SelectFont(Corsiva_12, ks0108ReadFontData, BLACK);<br />// Set a position<br />ks0108GotoXY(5,30);<br />// Print some text<br />ks0108Puts_P(PSTR(&quot;http://www.apetech.de\nmailto:me@apetech.de&quot;));<br /><br />while(1);<br />}[/syntax]<br /><br />Procesor Atmega32, środowisko Atmel Studio 6.2<br /><br />RS   &lt;&gt;    PORTC2<br />R/W &lt;&gt;    PORTC1<br />E     &lt;&gt;    PORTC0<br />CS1 &lt;&gt;    PORTC5<br />CS2 &lt;&gt;    PORTC6 <br />RST  wyświetlacza wisi w powietrzu, początkowo tak wszystko śmigało.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12382">klimeq</a> — 30 paź 2016, o 19:12</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[michal1210]]></name></author>
<updated>2016-10-30T19:10:08+01:00</updated>
<published>2016-10-30T19:10:08+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173205#p173205</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173205#p173205"/>
<title type="html"><![CDATA[Re: KS0108 [C]]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=16662&amp;p=173205#p173205"><![CDATA[
<div class="quotetitle">QuadMan napisał(a):</div><div class="quotecontent"><br />nie chciałem być tak dosadny jak Kolega michal1210<br /></div><br /><br />Przepraszam... <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /><br />Nie chciałem być dosadny, tylko zaznaczyć, że naprawdę na podstawie tego co kolego napisał nic się nie da pomóc.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=998">michal1210</a> — 30 paź 2016, o 19:10</p><hr />
]]></content>
</entry>
</feed>