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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2017-04-25T14:46:05+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=18255&amp;mode</id>
<entry>
<author><name><![CDATA[wchpikus]]></name></author>
<updated>2017-04-25T14:46:05+01:00</updated>
<published>2017-04-25T14:46:05+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18255&amp;p=187848#p187848</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18255&amp;p=187848#p187848"/>
<title type="html"><![CDATA[Spi a restart procka]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18255&amp;p=187848#p187848"><![CDATA[
Witam<br />Od razu przejdę do tematu.<br />Mam sterownik led na max7912, wszystko działa.<br />Niestety nie zadowala mnie prędkość sterowania, wiec postanowiłem przełączyć linie danych na sprzętowy spi.<br />I mam zonk.<br /><br />W momencie włączenia SPI:<br />[syntax=c]SPCR=(1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;SPR1);[/syntax]<br /><br />i probie wyslania czegokolwiek na SPI:<br />[syntax=c]uint8_t SendByte(uint8_t data){<br />// Load data into the buffer<br />SPDR = data;<br /><br />//Wait until transmission complete<br />while(!(SPSR &amp; (1&lt;&lt;SPIF) ));<br /><br />// Return received data<br />return(SPDR);<br />}[/syntax]<br /><br />[syntax=c]SendByte(jakas dana)[/syntax]<br /><br />program sie wywala..<br /><br />linia CS jest jako output, <br />[syntax=c]SET_PINPORT_AS_OUT (DDRB,PINB2);<br />SET_PINPORT_AS_OUT (DDRB,PINB3);<br />SET_PINPORT_AS_OUT (DDRB,PINB5);[/syntax]<br /><br />[syntax=c]#define SET_PINPORT_AS_OUT(ADDRES,PIN) (ADDRES |= (1&lt;&lt;PIN))[/syntax]<br /><br />Widze ze jakieś dane lecą na SPI, ale tylko do momentu wysłania, potem jest restart..<br /><br />linia MISO wisi w powietrzu, SS tez..<br /><br /><br /><br />Czy ktoś przerabiał sterowanie max-em po SPI?<br /><br />Obecnie wysyłanie zrealizowane jest tak:<br /><br />[syntax=c]void max7219_shiftout(uint8_t bytedata) {<br />            uint8_t j = 0;<br />            //the shift is made in reverse order for this ic<br />            for(j=8; j&gt;0; j--){<br />                    uint8_t val = (bytedata &amp; (1&lt;&lt;(j-1)))&gt;&gt;(j-1);<br />                    MAX7219_CLKPORT &amp;= ~(1 &lt;&lt; MAX7219_CLKINPUT); //set the serial-clock pin low<br />                    if(val)<br />                            MAX7219_DINPORT |= (1 &lt;&lt; MAX7219_DININPUT);<br />                    else<br />                            MAX7219_DINPORT &amp;= ~(1 &lt;&lt; MAX7219_DININPUT);<br />                    MAX7219_CLKPORT |= (1 &lt;&lt; MAX7219_CLKINPUT); //set the serial-clock pin high<br />            }<br />    }[/syntax]<br /><br />Chciałbym to przerobić na SPI..<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=3859">wchpikus</a> — 25 kwi 2017, o 14:46</p><hr />
]]></content>
</entry>
</feed>