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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2024-01-03T11:49:07+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=24607&amp;mode</id>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2024-01-03T11:49:07+01:00</updated>
<published>2024-01-03T11:49:07+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237795#p237795</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237795#p237795"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237795#p237795"><![CDATA[
Kurcze nawet o tym nie pomyślałem (－‸ლ)  faktycznie przecież tam robiłem to 10 razy dla 2 bajtów ,a w sprzętowym obleciałem 16bitów na &quot;siłę&quot; <img src="https://forum.atnel.pl/images/smilies/icon_lol.gif" alt=":lol:" title="Śmieje się" /> <br />stąd te przesunięcie i nawet się zgadza bo o 6 różnicy ten obraz się przesuwał.<br /><br />Tak musi wyglądać funkcja dla SOFT_SPI przy 2 bajtach i 16 bitach powyżej w  temacie jest dla tylko 10 bitów<br />To może jeszcze kolega wytłumaczy w linku  <br />[syntax=c]//potrzebna dla wyslania 10bitow dla <br />inline void send_spi4( uint16_t data ) {<br /><br />  if (data &amp; 0x8000) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />      if (data &amp; 0x4000) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br /><br /><br />  if (data &amp; 0x2000) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x1000) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br /><br /><br />  if (data &amp; 0x800) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x400) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br /><br />   if (data &amp; 0x200) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />   SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />   if (data &amp; 0x100) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />   SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />   if (data &amp; 0x80) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x40) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x20) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x10) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x08) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x04) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x02) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x01) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />//  <br />//  <br />//  for (uint8_t i = 16; i; i--) {                                     //i również 16 razy pętla  ;) <br />//  if (data &amp; 0x2000) MOSI_PORT |= MOSI; //tutaj również 16bitów<br />//  else MOSI_PORT &amp;= ~MOSI;<br />//  data &lt;&lt;= 1;<br />//  SCK_PORT |= SCK;<br />//  SCK_PORT &amp;= ~SCK;<br />//  }<br />//  <br />  <br />    <br /> }[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 3 sty 2024, o 11:49</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2024-01-02T19:34:05+01:00</updated>
<published>2024-01-02T19:34:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237790#p237790</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237790#p237790"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237790#p237790"><![CDATA[
Dobra po przypomnieniu jednego filmiku Mirka z SPI &quot;coś&quot; zrobiłem.  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br />I całe cyfry mi się świecą. <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> <br />Tylko nie rozumiem  dlaczego cały napis wyświetla się przy SPI Programowym o 4 pixele(w sensie że 5ty  pixel już się świeci) w prawo zaś <br />SPI sprzętowe jest od początku ekranu(w sumie o to mi chodzi  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" />  ) <br />[syntax=c]SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 4<br /> while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /> SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 3<br /> while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /> SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 2<br /> while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /> SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 1<br />  while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />  SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />  SPDR= (row&gt;&gt;8);<br />  while( !(SPSR &amp; (1&lt;&lt;SPIF)));<br />  SPDR=   row     ;<br />  while( !(SPSR &amp; (1&lt;&lt;SPIF)));<br />  LT_ON;<br />  LT_OFF;<br /><br />row &lt;&lt;= 1;// zwiększ licznik wierszy<br /><br />if( !row  ) {// jeśli licznik wierszy = 0<br /><br />                    row =1;// ustaw pierwszy wiersz<br /><br />row_byte_cnt =39;// RAMBUF_SIZE-1;// ustaw ostatni bajt bufora<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 2 sty 2024, o 19:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Marhef]]></name></author>
<updated>2023-12-31T21:29:27+01:00</updated>
<published>2023-12-31T21:29:27+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237787#p237787</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237787#p237787"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237787#p237787"><![CDATA[
A nie wystarczy wgrać wsad do zestawu, nawet bez podłączonych wyświetlaczy, i sprawdzić, co idzie na liniach danych?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=12752">Marhef</a> — 31 gru 2023, o 21:29</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[micky]]></name></author>
<updated>2023-12-31T19:26:26+01:00</updated>
<published>2023-12-31T19:26:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237786#p237786</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237786#p237786"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237786#p237786"><![CDATA[
Mozesz spróbować sie polutować kabelkami i analizatorem do docelowej płytki. Dla mnie byłby to najszybszy sposób spr co ląduje na magistrali. Z drugiej strony podłączenie wyświetlacza do zestawu chyba nie byłoby czasochłonne a byś wiedział co tak naprawdę się dzieje.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1546">micky</a> — 31 gru 2023, o 19:26</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2023-12-31T00:38:41+01:00</updated>
<published>2023-12-31T00:38:41+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237783#p237783</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237783#p237783"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237783#p237783"><![CDATA[
Poprawiłem jest na 4 Bajtach w kolumnach okazało się że w zmiennej<br />row_byte_cnt powinna być wartość  = 39 stĄD SET PIXEL mi na 4 bajtach nie działał xD<br /><br /><span style="color: #FF4080">Ale jeśli chodzi o sprzętowe SPI NADAL OBCINA MI GÓRNE 2 PIXELE</span><br /><br />[syntax=c]ISR( TIMER0_COMPA_vect) {<br />#else<br />ISR( TIMER2_COMP_vect ) {<br />#endif<br />//###############DEFINICJE ZMIENNYCH<br />static uint16_t row=1;// licznik wierszy<br />static uint8_t row_byte_cnt = RAMBUF_SIZE-1;// licznik bajtów bufora<br /><br />#if SPI_SOFT == 1<br />//###############sprzetowe SPI######################<br /> <br /> //aktywacja  SPI, tryb pracy Master, prędkość zegara Fosc/2<br />  SPCR |= (1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;DORD);<br />        SPSR |= (1&lt;&lt;SPI2X); <br />  <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 4<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />     // SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />    //  SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 3<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />      //    SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />  //    SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br /> <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 2<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />                 <br />     <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 1<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /><br /><br /> SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71 bez tego jest do gory nogami napis<br /> <br /> //SPDR =   row; <br /> SPDR =   row; <br />     while( !(SPSR &amp; (1&lt;&lt;SPIF)));<br /> <br /> <br /><br /> <br /><br /><br />// zatrzask rejestrów<br />LT_ON;<br />LT_OFF;<br />// zwiększ licznik wierszy<br />row &lt;&lt;= 1;<br /><br />if( !row ) {// jeśli licznik wierszy = 0<br />row = 1;// ustaw pierwszy wiersz<br /><br />row_byte_cnt = 39;//RAMBUF_SIZE-1 ;//;49;// ustaw ostatni bajt bufora<br />}<br /><br /><br /> <br /><br /><br /><br />#else<br />//+++++++++++++++++PROGRAMOWE SPI+++++++++++++++++++++++++++++<br /> <br />  <br /> <br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 4<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 3<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 2<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 1<br />//send_spi( row );// wyślij bajt nr   (ustal wiersz)<br />send_spi4( row );//WYSLIJ 2 BAJTY   DLA 10 WIERSZY wyślij bajt nr (ustal wiersz)<br />// zatrzask rejestrów<br />LT_ON;<br />LT_OFF;<br />// zwiększ licznik wierszy<br />row &lt;&lt;= 1;<br /><br />if( !row ) {// jeśli licznik wierszy = 0<br />row =1;// ustaw pierwszy wiersz<br />row_byte_cnt = 39;// ustaw ostatni bajt bufora<br />}  <br />#endif<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 31 gru 2023, o 00:38</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2023-12-30T21:46:02+01:00</updated>
<published>2023-12-30T21:46:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237782#p237782</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237782#p237782"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237782#p237782"><![CDATA[
<div class="quotetitle">micky napisał(a):</div><div class="quotecontent"><br />A patrzyłeś analizatorem co się dzieje na magistrali?<br /></div><br /><br />Sugerujesz że szybkość jest zbyt duża dla 5 Bajtów przy sprzętowym SPI ?<br /><br />Trochę miałbym problem z podłączeniem się do pinów bo to na gotowych płytkach to robię musiałbym się teraz na zestaw przerzucać <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /> nie bardzo mi się uśmiecha teraz  w to się bawić.<br /><br />Dałem tam 5 bajtów ponieważ nie mogłem sobie poradzić z ustawieniem funkcji set pixel a jak zmieniłem tak:<br />[syntax=c]void set_pixel2( int x, int y, uint8_t color ) {<br /><br />//warunek ktory rysyje <br />//tutaj dalem y mniejsze od 7 bo 6 bitow zjedzone nie<br />if( x&lt;6|| x&gt;MATRIX_WIDTH-1 || y&lt;0 || y&gt;MATRIX_HEIGHT-1 ) return;<br /><br />if( color ) rambuf&#91; (x/8) + ((y%10)*5)  &#93; |=  ( 1 &lt;&lt; ( 7- (x % 8)) );<br />else rambuf&#91; (x/8) + ((y%10)*5) &#93; &amp;=  ~( 1 &lt;&lt; ( 7- (x % 8)) );<br />           //indeks dla 5 bajtów dlatego mnożone razy &quot;5&quot;<br />}[/syntax]<br /><br />To udało mi się aby funkcja ta działała prawidłowo ale dla 5 bajtów (kolumny)  Może jeśli dacie jakieś wskazówki jak przerobić ją dla 4 bajtów wiem że pomnożyć przez 4 ale to nic nie daje bo są śmieci (wiem że trzeba dokonać zmiany  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" />  w warunku na row_byte_cnt = 31;<br />// ustaw ostatni bajt bufora )<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 30 gru 2023, o 21:46</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[micky]]></name></author>
<updated>2023-12-30T20:32:56+01:00</updated>
<published>2023-12-30T20:32:56+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237781#p237781</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237781#p237781"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237781#p237781"><![CDATA[
A patrzyłeś analizatorem co się dzieje na magistrali?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1546">micky</a> — 30 gru 2023, o 20:32</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2023-12-30T19:34:37+01:00</updated>
<published>2023-12-30T19:34:37+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237780#p237780</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237780#p237780"/>
<title type="html"><![CDATA[Re: Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237780#p237780"><![CDATA[
<div class="quotetitle">ord napisał(a):</div><div class="quotecontent"><br />SPDR = (row&gt;&gt;2) ;      // ??!<br />...<br />                   SPDR = (row &amp; 0x200);<br />...<br /></div><br /><br />To akurat zapomniałem wyciąć bo to tylko testy były  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br /><br /><br />Normalnie to wygląda tak:<br />[syntax=c]SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 5<br /> while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /><br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 4<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />    <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 3<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />     <br /> <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 2<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />                 /<br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 1<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /><br />                       SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />       SPDR =   row; <br />       while( !(SPSR &amp; (1&lt;&lt;SPIF)));// wyślij bajt nr 0 (ustal wiersz)<br /> <br /> <br /><br /> <br /><br /><br />// zatrzask rejestrów<br />LT_ON;<br />LT_OFF;<br />// zwiększ licznik wierszy<br />row &lt;&lt;= 1;<br /><br />if( !row ) {// jeśli licznik wierszy = 0<br />row = 0x0001;// ustaw pierwszy wiersz<br /><br />row_byte_cnt = 49;//RAMBUF_SIZE-1 ;//;49;// ustaw ostatni bajt bufora<br />}[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 30 gru 2023, o 19:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[RadekB86]]></name></author>
<updated>2023-12-30T14:39:26+01:00</updated>
<published>2023-12-30T14:39:26+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237776#p237776</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237776#p237776"/>
<title type="html"><![CDATA[Jak wysłać 10 bitów po sprzętowym SPI atmega328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=24607&amp;p=237776#p237776"><![CDATA[
Pytanie dotyczy tego tematu czyt. urządzenia: <!-- l --><a class="postlink-local" href="https://forum.atnel.pl/topic24604.html" >topic24604.html</a><!-- l --><br />Napisałem PROGRAMOWE SPI przesyłanie obrazu i ono mi działa jak najbardziej prawidłowo  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br />czyli zarówno wysyła mi dobrze  wiersze i kolumny<br /><span style="color: #FF00FF">ALE MAM PROBLEM ZE SPRZĘTOWYM OBCINA MI ZNAKI I JE NAWET PRZENOSI W INNĄ LOKALIZACJE NA EKRANIE</span> <img src="https://forum.atnel.pl/images/smilies/icon_mrgreen.gif" alt=":mrgreen:" title="Pan Zielony" /> <br />[syntax=c]ISR( TIMER0_COMPA_vect) {<br />#else<br />ISR( TIMER2_COMP_vect ) {<br />#endif<br />//###############DEFINICJE ZMIENNYCH<br />static uint16_t row=1;// licznik wierszy<br />static uint8_t row_byte_cnt = RAMBUF_SIZE-1;// licznik bajtów bufora<br /><br />#if SPI_SOFT== 0<br />//###############sprzetowe SPI######################<br /> <br /> //aktywacja  SPI, tryb pracy Master, prędkość zegara Fosc/2 <br />SPCR |= (1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;DORD);<br />SPSR |= (1&lt;&lt;SPI2X); <br /> <br />      <br />       //SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />      // SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br /> SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 5<br /> while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /> //  SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />   //  SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br /> <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 4<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />     // SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />    //  SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 3<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />      //    SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />  //    SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br /> <br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 2<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br />                 //  SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />     // SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br />SPDR = rambuf&#91; row_byte_cnt-- &#93;;// wyślij bajt nr 1<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)) );<br /><br /><br />                   SPCR&amp;= ~(1&lt;&lt;DORD);//zanegowanie bitu str.71<br />                 // SPCR |= (1&lt;&lt;DORD);//ustawienie bitu str.71<br />                   <br />SPDR = (row&gt;&gt;2) ;// wyślij bajt nr 0 (ustal wiersz)<br />while( !(SPSR &amp; (1&lt;&lt;SPIF)));<br /><br />// (row&gt;&gt;2)<br />   SPDR = (row &amp; 0x200);<br />   while( !(SPSR &amp; (1&lt;&lt;SPIF)));<br /> <br /><br /> <br /><br /><br />// zatrzask rejestrów<br />LT_ON;<br />LT_OFF;<br />// zwiększ licznik wierszy<br />row &lt;&lt;= 1;<br /><br />if( !row ) {// jeśli licznik wierszy = 0<br />row = 1;// ustaw pierwszy wiersz<br />row_byte_cnt = 49;//RAMBUF_SIZE-1 ;//;49;// ustaw ostatni bajt bufora<br />}<br /><br /><br /> <br /><br /><br /><br />#else<br />//+++++++++++++++++PROGRAMOWE SPI+++++++++++++++++++++++++++++<br /> <br />  <br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 5<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 4<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 3<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 2<br />send_spi3( rambuf&#91; row_byte_cnt-- &#93; );// wyślij bajt nr 1<br />//send_spi( row );// wyślij bajt nr   (ustal wiersz)<br />send_spi4( row );//WYSLIJ 2 BAJTY   DLA 10 WIERSZY wyślij bajt nr (ustal wiersz)<br />// zatrzask rejestrów<br />LT_ON;<br />LT_OFF;<br />// zwiększ licznik wierszy<br />row &lt;&lt;= 1;<br /><br />if( !row ) {// jeśli licznik wierszy = 0<br />row =1;// ustaw pierwszy wiersz<br />row_byte_cnt = 49;// ustaw ostatni bajt bufora<br />}  <br />#endif<br />}[/syntax]<br /><br /><br />Oczywiście programowe SPI wygląda trochę zmienione dla wierszy niż kolumn bo mam tam 10 bitów a więc 2bajty tak wyglądają te funkcje  SEND SPI3:<br />[syntax=c]// wyślij jeden bajt przez soft SPI<br />inline void send_spi3( uint8_t data ) {<br /><br />if( data &amp; 0x01 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x02 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x04 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x08 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x10 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x20 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x40 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br />if( data &amp; 0x80 ) MOSI_PORT |= MOSI; else MOSI_PORT &amp;= ~MOSI;<br />SCK_PORT |= SCK; SCK_PORT &amp;= ~SCK;<br /><br />//for (uint8_t i = 8; i; i--) {<br />//if (data &amp; 0x01) MOSI_PORT |= MOSI;<br />//else MOSI_PORT &amp;= ~MOSI;<br />//data &gt;&gt;= 1;<br />//SCK_PORT |= SCK;<br />//SCK_PORT &amp;= ~SCK;<br />//}<br />}[/syntax]<br /><br /><br />a TAK wygląda send_spi4 :<br />[syntax=c]//potrzebna dla wyslania 10bitow dla <br />inline void send_spi4( uint16_t data ) {<br /><br />   <br />  if (data &amp; 0x200) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x100) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x80) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x40) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x20) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x10) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x08) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x04) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x02) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  if (data &amp; 0x01) MOSI_PORT |= MOSI;else MOSI_PORT &amp;= ~MOSI;<br />  SCK_PORT |= SCK;SCK_PORT &amp;= ~SCK;<br />  <br />//  <br />//  for (uint8_t i = 10; i; i--) {<br />//  if (data &amp; 0x200) MOSI_PORT |= MOSI;<br />//  else MOSI_PORT &amp;= ~MOSI;<br />//  data &lt;&lt;= 1;<br />//  SCK_PORT |= SCK;<br />//  SCK_PORT &amp;= ~SCK;<br />//  }<br />//  <br />  <br />    <br /> }[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1837">RadekB86</a> — 30 gru 2023, o 14:39</p><hr />
]]></content>
</entry>
</feed>