Uplne cely program poslat nemuzu, jen znacne upraveny vytah:<br>
<p class="MsoNormal" style=""><br></p><p class="MsoNormal" style="">#define TLED_ON PORTD |= (0x80)<br>
#define TLED_OFF PORTD &= ~(0x80)</p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(63, 127, 95);"><br></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(63, 127, 95);">void SPI_Slave_Init(void)<br>
{<br> DDR_SPI2 = (1<<MISO2);<br> SPI2_PORT = (1<<SCK2)|(1<<MOSI2)|(1<<CS2);<br> SPCR = (1<<SPIE)|(1<<SPE)|(1<<MSTR)|(1<<CPOL)|(1<<CPHA);<br>}</span></p><p class="MsoNormal" style="">
<span style="font-size: 10pt; font-family: "Courier New"; color: rgb(63, 127, 95);"><br></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(63, 127, 95);">//<u>Preruseni</u>
<u>od</u> SPI</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;">ISR</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">SPI_STC_vect</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">{</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: green;">uint8_t</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> length = 10;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><span style="font-size: 10pt; font-family: "Courier New"; color: green;">uint8_t</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> data;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><span style="font-size: 10pt; font-family: "Courier New"; color: green;">uint8_t</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> a;<span style=""> </span></span></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> </span></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: black;">cli</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">()</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>SPCR = </span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">0<<SPIE</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<SPE</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">0<<MSTR</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<CPOL</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<CPHA</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>TLED_ON;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>SPDR = 0x02</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;" lang="EN-US">;</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-US"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">do</span></b><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">{</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style="margin-left: 35.4pt; text-indent: 35.4pt;"><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">#define</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> delay 300</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">for</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">a=0;a<delay;a++</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> </span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">if</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">((</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">SPSR&0x80</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">))</span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">break</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""></span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span><span style=""> ...</span><br></span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> data
= SPDR;</span></p><p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"> SPDR = pole[data];</span><br><span style="font-size: 10pt; font-family: "Courier New"; color: black;"></span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""> .....<br></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">}</span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">while</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">--length</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>TLED_OFF;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>SPCR = </span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<SPIE</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<SPE</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<MSTR</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<CPOL</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">|</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">(</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">1<<CPHA</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">)</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span>sei</span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">()</span><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: black;"><span style=""> </span></span><b><span style="font-size: 10pt; font-family: "Courier New"; color: rgb(127, 0, 85);">return</span></b><span style="font-size: 10pt; font-family: "Courier New"; color: black;">;</span><span style="font-size: 10pt; font-family: "Courier New";"></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">}</span></p><p class="MsoNormal"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;"><br>
</span></p>
Ve smycce while je toho samozrejme vice, s problemem to ale nesouvisi. Nektere veci v kodu jsem pridaval a menil nahodne ze zoufalstvi, nic nepomohlo.<br>To zpozdeni jsem zjistoval pomoci LA napichnuteho na SPI + jeden I/O pin AVR jako signalizace kdy jsem v preruseni.<br>
Problem se vyskytuje uplne nahodne, tj. treba mnohostokrat do preruseni skocim ihned po shozeni /SS, semtam az po prijeti jednoho byte.<br>KM<br><br><br><br><div class="gmail_quote">2011/2/28 Jan Waclawek <span dir="ltr"><<a href="mailto:konfera@efton.sk">konfera@efton.sk</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">----- Original Message ---------------<br>
>Uvnitr<br>
>preruseni zakazu globalni preruseni (cli)<br>
<br>
</div><div class="im">To je zbytocne, vyvolanim prerusenia sa automaticky dalsie prerusenia zakazu (procesor automaticky vynuluje flag I).<br>
<br>
>Zjistil jsem pomoci log. analyzeru ze v AVR se<br>
>vyvolalo preruseni pozde, az po prijmu prvniho byte a ne hned po shozeni<br>
>/SS.<br>
<br>
</div>Ako presne ste to zistovali? Mozete poslat program?<br>
<br>
wek<br>
<br>
<br>
<br>
_______________________________________________<br>
HW-list mailing list - sponsored by <a href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
<a href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a><br>
<a href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
</blockquote></div><br>