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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2017-04-23T23:16:02+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=18239&amp;mode</id>
<entry>
<author><name><![CDATA[danny]]></name></author>
<updated>2017-04-23T23:16:02+01:00</updated>
<published>2017-04-23T23:16:02+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187753#p187753</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187753#p187753"/>
<title type="html"><![CDATA[Re: implementacja protokolu z m8 na m328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187753#p187753"><![CDATA[
Tak na szybko analiza tylko wklejonego  kawałka kodu:<br /><br />To co kol. Kicajek napisał plus:<br /><br />1. W atmedze328p nie ma rejestru GICR - jest EIMSK<br />2. Nie ma MCUCR - jest EICRA<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1505">danny</a> — 23 kwi 2017, o 23:16</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Moriusz]]></name></author>
<updated>2017-04-23T22:50:23+01:00</updated>
<published>2017-04-23T22:50:23+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187751#p187751</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187751#p187751"/>
<title type="html"><![CDATA[Re: implementacja protokolu z m8 na m328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187751#p187751"><![CDATA[
jak mowilem jest to tylko kod z atm8 i nie do konca dzialajacy zauwazony problem z deklaracja spi chodzi mi bardziej o vektory <br />Edit kod zmieniony<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=17025">Moriusz</a> — 23 kwi 2017, o 22:50</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[kicajek]]></name></author>
<updated>2017-04-23T22:22:49+01:00</updated>
<published>2017-04-23T22:22:49+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187748#p187748</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187748#p187748"/>
<title type="html"><![CDATA[Re: implementacja protokolu z m8 na m328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187748#p187748"><![CDATA[
Witam<br />Tak wyczerpująco opisałeś problem, że zaraz zawiesi się serwer od odpowiedzi  <img src="https://forum.atnel.pl/images/smilies/icon_e_wink.gif" alt=";)" title="Puszcza oko" /> <br />Nie robiłem nic na ATm328, ale w iom328p.h nie ma takich makr:<br />DDRB |= (1&lt;&lt;<strong>PB5</strong>) | (1&lt;&lt;<strong>PB7</strong>)| (1&lt;&lt;DDB4); <br />...no chyba że kompilator wie.<br />Edytuj kod na postać &quot;C&quot; a nie &quot;kod jako kod&quot; - źle się czyta.<br />Jeśli ECLIPSE to wywal to nieszczęsne:<br /><strong>#define F_CPU 8000000UL</strong><br /><br />Pozdr.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=826">kicajek</a> — 23 kwi 2017, o 22:22</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Moriusz]]></name></author>
<updated>2017-04-23T22:53:48+01:00</updated>
<published>2017-04-23T21:37:03+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187743#p187743</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187743#p187743"/>
<title type="html"><![CDATA[implementacja protokolu z m8 na m328p]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=18239&amp;p=187743#p187743"><![CDATA[
Witam forumowiczow, <br />Mam malutki problem z implementacja protokolu komunikacji radia ze zmieniarka.... <br />Ale od poczatku:<br />Znam interwaly impulsow generalnie caly protokol jest opisany.<br /><div class="quotetitle"><b>Quote:</b></div><div class="quotecontent"><br />There are three different bit identifiers<br /><br />    Start bit: It consists of a 9ms high phase followed by a 4.5ms low phase.<br />    0-Bit: A bit with a value of 0, is represented by an equal-long high and low phase. The length is in each case 0.55 ms. The bit thus has a total length of 1.1 ms.<br />    1 bit: A bit with a value of 1, represents a 0.55 ms long high pulse followed by a 1.7 ms low phase. The total length is therefore 2.25 ms. <br /><br />A command consists of 4 bytes, whereby in my interpretation the LSB (least significant bit) of each byte is sent first.<br /><br />    1st byte: always CA hex.<br />    2nd byte: always 34 hex.<br />    3. Byte: The command which is evaluated.<br />    4. Byte: Again the command with inverted bit. <br /><br />The bit sequence &quot;01010011 00101100 01111000 10000111&quot; can be seen in the figure above. This corresponds to the hexadecimal representation &quot;CA 34 1e e1&quot;. In this case, the radio has indicated that the next track should be played.<br /></div><br /><br /><br />Posiadam rowniez kod napisany na Atmega8 ale niestety jest nie kompatybilny z Atmega328 albo ja cos robie zle ... <br /><br />[syntax=c]/*<br />* VAG_CDC.c<br />*<br />* Created: 23.06.2013 20:00:51<br />*  Author: Dennis Schuett, dev.shyd.de<br />*/ <br />#define F_CPU 8000000UL<br />#include &lt;inttypes.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &quot;uart.h&quot;<br />#define UART_BAUD_RATE 9600<br />#define LED_PWR PA0<br />#define RADIO_OUT PD2<br />#define FT_CBUS1 PD3<br />#define RADIO_OUT_IS_HIGH (PIND &amp; (1&lt;&lt;RADIO_OUT))<br />#define CDC_PREFIX1 0x53<br />#define CDC_PREFIX2 0x2C<br />#define CDC_END_CMD 0x14<br />#define CDC_PLAY 0xE4<br />#define CDC_STOP 0x10<br />#define CDC_NEXT 0xF8<br />#define CDC_PREV 0x78<br />#define CDC_SEEK_FWD 0xD8<br />#define CDC_SEEK_RWD 0x58<br />#define CDC_CD1 0x0C<br />#define CDC_CD2 0x8C<br />#define CDC_CD3 0x4C<br />#define CDC_CD4 0xCC<br />#define CDC_CD5 0x2C<br />#define CDC_CD6 0xAC<br />#define CDC_SCAN 0xA0<br />#define CDC_SFL 0x60<br />#define CDC_PLAY_NORMAL 0x08<br />#define MODE_PLAY 0xFF<br />#define MODE_SHFFL 0x55<br />#define MODE_SCAN 0x00<br />uint16_t captimehi = 0;<br />uint16_t captimelo = 0;<br />uint8_t capturingstart = 0;<br />uint8_t capturingbytes = 0;<br />uint32_t cmd = 0;<br />uint8_t cmdbit = 0;<br />uint8_t newcmd = 0;<br />uint8_t shutdownpending = 0;<br />uint8_t getCommand(uint32_t cmd);<br />void shutdown();<br />void softreset();<br />volatile uint8_t cd;<br />volatile uint8_t tr;<br />volatile uint8_t mode;<br />ISR(INT0_vect) //remote signals<br />{<br />if(RADIO_OUT_IS_HIGH)<br />{<br />if (capturingstart || capturingbytes)<br />{<br />captimelo = TCNT1;<br />}<br />else<br />capturingstart = 1;<br />TCNT1 = 0;<br />//eval times<br />if (captimehi &gt; 8300 &amp;&amp; captimelo &gt; 3500)<br />{<br />capturingstart = 0;<br />capturingbytes = 1;<br />//uart_puts(&quot;startseq found\r\n&quot;);<br />}<br />else if(capturingbytes &amp;&amp; captimelo &gt; 1500)<br />{<br />//uart_puts(&quot;bit 1\r\n&quot;);<br />cmd = (cmd&lt;&lt;1) | 0x00000001;<br />cmdbit++;<br />}<br />else if (capturingbytes &amp;&amp; captimelo &gt; 500)<br />{<br />//uart_puts(&quot;bit 0\r\n&quot;);<br />cmd = (cmd&lt;&lt;1);<br />cmdbit++;<br />}<br />else<br />{<br />//uart_puts(&quot;nothing found\r\n&quot;);<br />}<br />if(cmdbit == 32)<br />{<br />//uart_puts(&quot;new cmd\r\n&quot;);<br />newcmd = 1;<br />cmdbit = 0;<br />capturingbytes = 0;<br />}<br />}<br />else<br />{<br />captimehi = TCNT1;<br />TCNT1 = 0;<br />}<br />}<br /><br />int main(void)<br />{<br />cd = 0xBE;<br />tr = 0xFF;<br />mode = 0xFF;<br />//LEDs<br />//pullup<br />uart_init(UART_BAUD_SELECT(UART_BAUD_RATE, F_CPU));<br /><br />TCCR1B |= (1&lt;&lt;CS11);    // no prescaler 8 -&gt; 1 timer clock tick is 1us long<br />GICR |= (1&lt;&lt;INT0) | (1&lt;&lt;INT1);<br />MCUCR |= (1&lt;&lt;ISC00) | (1&lt;&lt;ISC10); //any change on INT0 and INT1<br />sei();<br />//init led on<br /><br />_delay_ms(500);<br />//uart_puts(&quot;VAG_CDC ready...\r\n&quot;);<br />uart_putc(0xAA);<br />uart_putc(0x55);<br /><br />while(1)<br />{<br />int r = uart_getc();<br />//r has new data<br />if(r &lt;= 0xFF)<br />{<br />//send inverted CD No.<br />if((r &amp; 0xC0) == 0xC0)<br />{<br />if (r == 0xCA)<br />mode = MODE_SCAN;<br />else if (r == 0xCB)<br />mode = MODE_SHFFL;<br />else if (r == 0xCC)<br />mode = MODE_PLAY;<br />else<br />cd = 0xFF^(r &amp; 0x0F);<br />}<br />//send inverted TR No.<br />else<br />tr = 0xFF^r;<br />}<br /><br />_delay_ms(41);<br />if (newcmd)<br />{<br />newcmd = 0;<br />uint8_t c = getCommand(cmd);<br />if (c)<br />{<br />uart_putc(c);<br /><br />}<br />}<br />}<br />}<br />uint8_t getCommand(uint32_t cmd)<br />{<br />if (((cmd&gt;&gt;24) &amp; 0xFF) == CDC_PREFIX1 &amp;&amp; ((cmd&gt;&gt;16) &amp; 0xFF) == CDC_PREFIX2)<br />if (((cmd&gt;&gt;8) &amp; 0xFF) == (0xFF^((cmd) &amp; 0xFF)))<br />return (cmd&gt;&gt;8) &amp; 0xFF;<br />return 0;<br />}[/syntax]<br /><br /><br />Generalnie nie potrzebuje poprawienia spi wysylki i odbierania bo to juz mam i dziala poprawnie bardzie martwi mnie ISR(INT0_vect) oraz deklaracje rejestrow/Timerow.<br />Moja wiedza na temat C w AVR jest slaba ale ciagle czytam i sie szkole ale na tym poleglem nie potrafie tego sportowac, lub napisac od zera.<br /><br />Przepraszam za brak pl znaczkow. <br />Dziekuje za kazda informacje, naprowadzenie na wlasciwy trop.<br />Pozdrawiam<br />Piotr<br />P.S.<br />Panie Mirku dzieki za Eclipsa<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=17025">Moriusz</a> — 23 kwi 2017, o 21:37</p><hr />
]]></content>
</entry>
</feed>