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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2013-07-24T14:27:01+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=30&amp;t=3644&amp;mode</id>
<entry>
<author><name><![CDATA[Wojtek001]]></name></author>
<updated>2013-07-24T14:27:01+01:00</updated>
<published>2013-07-24T14:27:01+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43154#p43154</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43154#p43154"/>
<title type="html"><![CDATA[Re: SPI i MISO jako CS/SS]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43154#p43154"><![CDATA[
Znalazłem w tabelce że w rybie master MISO musi być wejściem. Jedynie nadzieja że może będzie dało się coś na tej nóżce badać niezależnie od SPI (od biedy mogę przecież nawet sczytywać dane z bufora wejściowego w celu badania np. stanu przycisku).<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=500">Wojtek001</a> — 24 lip 2013, o 14:27</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Jaglarz]]></name></author>
<updated>2013-07-24T14:20:11+01:00</updated>
<published>2013-07-24T14:20:11+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43152#p43152</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43152#p43152"/>
<title type="html"><![CDATA[Re: SPI i MISO jako CS/SS]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43152#p43152"><![CDATA[
<div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />Przepraszam, ale dlaczego SYNTAX'a nie ma wśród przycisków do edycji czcionki?<br /></div><br /><br />Masz listę <strong>Syntax wybierz </strong>i wtedy wybiera się C.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=471">Jaglarz</a> — 24 lip 2013, o 14:20</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[barney]]></name></author>
<updated>2013-07-24T14:06:06+01:00</updated>
<published>2013-07-24T14:06:06+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43151#p43151</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43151#p43151"/>
<title type="html"><![CDATA[Re: SPI i MISO jako CS/SS]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43151#p43151"><![CDATA[
<div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />When the SPI is configured as a Master (MSTR in SPCR is set), the user can determine the<br />direction of the SS pin.<br />If SS is configured as an output, the pin is a general output pin which does not affect the SPI<br />system. Typically, the pin will be driving the SS pin of the SPI Slave.<br />If SS is configured as an input, it must be held high to ensure Master SPI operation. If the SS pin<br />is driven low by peripheral circuitry when the SPI is configured as a Master with the SS pin<br />defined as an input, the SPI system interprets this as another Master selecting the SPI as a<br />Slave and starting to send data to it. To avoid bus contention, the SPI system takes the following<br />actions:<br />1. The MSTR bit in SPCR is cleared and the SPI system becomes a Slave. As a result of<br />the SPI becoming a Slave, the MOSI and SCK pins become inputs.<br />2. The SPIF Flag in SPSR is set, and if the SPI interrupt is enabled, and the I-bit in SREG is<br />set, the interrupt routine will be executed.<br />Thus, when interrupt-driven SPI transmission is used in Master mode, and there exists a possibility<br />that SS is driven low, the interrupt should always check that the MSTR bit is still set. If the<br />MSTR bit has been cleared by a Slave Select, it must be set by the user to re-enable SPI Master<br />mode.<br /></div>O tym pamiętaj, 2 godziny życia przez to cholerstwo straciłem <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br /><br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />SPI Pin Overrides<br /><br />Pin Direction,        Master SPI Direction,              Slave SPI<br />MOSI,           User Defined,             Input<br />MISO,          Input,               User Defined<br />SCK,           User Defined,          Input<br />SS,             User Defined,            Input<br /></div> A z tego, wynika, że raczej nie da tak rady, ale możesz spróbować <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=973">barney</a> — 24 lip 2013, o 14:06</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Wojtek001]]></name></author>
<updated>2013-07-24T13:46:18+01:00</updated>
<published>2013-07-24T13:46:18+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43149#p43149</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43149#p43149"/>
<title type="html"><![CDATA[SPI i MISO jako CS/SS]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=3644&amp;p=43149#p43149"><![CDATA[
Używam SPI (sprzętowego) w m32 ale zaszła potrzeba użycia nóżki MISO jako SS (sygnał zatrzaskujący - CS). Czy jest to możliwe?<br /><br />Oto prościutki, testowy program napisany z przykładów zawartych w nocie i książce:<br /><br />Kod programu: [syntax=c]#include &lt;avr/io.h&gt;<br />    #include &lt;util/delay.h&gt;<br /><br />    #define MOSI PB5<br />    #define SCK PB7<br />    #define CS PB4<br /><br />    void InitSpi(void){DDRB |= (1&lt;&lt;MOSI)|(1&lt;&lt;SCK)|(1&lt;&lt;CS);SPCR |= (1&lt;&lt;SPE)|(1&lt;&lt;MSTR)|(1&lt;&lt;SPR1);}<br />    void SendSpi(uint8_t bajt){SPDR = bajt;while(!(SPSR &amp; (1&lt;&lt;SPIF)));}<br /><br />    int main(void)<br />    {<br />    DDRD |= (1&lt;&lt;PD7);<br />    InitSpi();<br />    while(1)<br />    {SendSpi(165);PORTB |=(1&lt;&lt;CS);_delay_ms(10);PORTB &amp;= ~(1&lt;&lt;CS);<br />    _delay_ms(1000);PORTD ^= (1&lt;&lt;PD7);<br />    }<br />    }[/syntax]<br /><br />Program co sekundę miga diodą na pinie PD7 (służy do debugowania) i co sekundę wysyła bajt 165 (działa poprawnie). Problem polega na tym że gdy podmienię w definicjach preprocesora CS z PB4 na PB6 (MISO) i przeniosę ustawianie CS jako wyjście na koniec funkcji InitSpi lub tuż przed wywoływaniem funkcji SendSpi. Program się zawiesza (z migania diody wynika że ostatnia linia pętli while wykonuje się raz lub wcale.<br /><br />Czy jest jakiś sposób aby użyć pinu MISO jako sygnał zatrzaskujący ? Może jest możliwość lepszej konfiguracji SPI do moich zastosowań.<br /><br /><span style="color: #FF0000">Kod umieszczamy przy pomocy syntax=c - Zielony J.</span><br /><span style="color: #008000">Przepraszam, ale dlaczego SYNTAX'a nie ma wśród przycisków do edycji czcionki?</span><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=500">Wojtek001</a> — 24 lip 2013, o 13:46</p><hr />
]]></content>
</entry>
</feed>