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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-07-05T17:34:15+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=8&amp;t=7673&amp;mode</id>
<entry>
<author><name><![CDATA[Janadamis]]></name></author>
<updated>2014-07-05T17:34:15+01:00</updated>
<published>2014-07-05T17:34:15+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86689#p86689</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86689#p86689"/>
<title type="html"><![CDATA[Re: [Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86689#p86689"><![CDATA[
W skrócie nie masz inicjalizacji I2C ani ustawiania prędkości transmisji. Po drugie po co w kodzie jest timer? który tutaj nie widać aby był używany tak samo uart. Wyrzuć te niepotrzebne rzeczy i testuj samą transmisje pomiędzy uC a RTC. A potem dodawaj kolejne. po za tym w BB masz już cały plik main.c wiec po co go zmieniałeś?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=288">Janadamis</a> — 5 lip 2014, o 17:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Nefarious19]]></name></author>
<updated>2014-07-05T17:23:41+01:00</updated>
<published>2014-07-05T17:23:41+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86688#p86688</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86688#p86688"/>
<title type="html"><![CDATA[Re: [Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86688#p86688"><![CDATA[
Pokaż mi w którym momencie ustawiasz prędkość transmisji po magistrali <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=2500">Nefarious19</a> — 5 lip 2014, o 17:23</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[4MaticPL]]></name></author>
<updated>2014-07-05T14:28:03+01:00</updated>
<published>2014-07-05T14:28:03+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86671#p86671</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86671#p86671"/>
<title type="html"><![CDATA[Re: [Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86671#p86671"><![CDATA[
Hmm. Na pewno w bb jest opisane jak zainicializować ten moduł do pracy?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2175">4MaticPL</a> — 5 lip 2014, o 14:28</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[majster]]></name></author>
<updated>2014-07-05T12:05:28+01:00</updated>
<published>2014-07-05T12:05:28+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86661#p86661</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86661#p86661"/>
<title type="html"><![CDATA[Re: Odp: [Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86661#p86661"><![CDATA[
I2c jest w bb wiec nie dawaj kodu na forum.<br />u ciebie jest brak inicjalizacji i2c zagladnij do bb i przeczytaj jeszcze raz rozdzial o i2c.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1628">majster</a> — 5 lip 2014, o 12:05</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Paul Dirac]]></name></author>
<updated>2014-07-05T11:20:47+01:00</updated>
<published>2014-07-05T11:20:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86656#p86656</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86656#p86656"/>
<title type="html"><![CDATA[Re: [Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86656#p86656"><![CDATA[
a gdzie jest inicjalizacja i2c?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1035">Paul Dirac</a> — 5 lip 2014, o 11:20</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[4MaticPL]]></name></author>
<updated>2014-07-05T10:47:52+01:00</updated>
<published>2014-07-05T10:47:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86651#p86651</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86651#p86651"/>
<title type="html"><![CDATA[[Problem] Moje początki z magistralą I2C]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=7673&amp;p=86651#p86651"><![CDATA[
Witam<br />Mam problem z obsłużeniem RTC. Program oczywiście zrobiony według BlueBooka:<br /><br />main.c<br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />#include &quot;MKUART/mkuart.h&quot;<br />#include &quot;Terminal/term.h&quot;<br />#include &quot;I2C/i2c.h&quot;<br /><br />volatile uint16_t Timer1, Timer2;<br /><br />enum {ss, mm, hh};<br /><br />uint8_t bufor&#91;3&#93;;<br />uint8_t sekundy, minuty, godziny;<br /><br /><br /><br />int main(void) {<br /><br />USART_Init( __UBRR );<br /><br />//***********************Ustawienie TIMER0*************************<br />TCCR0 |= (1&lt;&lt;WGM01);// tryb pracy CTC<br />TCCR0 |= (1&lt;&lt;CS02)|(1&lt;&lt;CS00);// preskaler = 1024<br />OCR0 = 15;// przerwanie porównania co 100Hz<br />TIMSK |= (1&lt;&lt;OCIE0);// Odblokowanie przerwania CompareMatch<br />//*****************************************************************<br /><br />sei();<br /><br />term_clear();<br />term_cursor_hide(1);<br />term_locate(2,2);<br />term_color_write(3);<br /><br /><br />uart_puts(&quot;Test I2C&quot;);<br /><br />term_locate(1, 30);<br /><br /><br />TWI_read_buf(0xA2, 0x02, 3, bufor);<br />sekundy = bcd2dec( bufor&#91;ss&#93; );<br />minuty = bcd2dec( bufor&#91;mm&#93; );<br />godziny = bcd2dec( bufor&#91;hh&#93; );<br /><br /><br />uart_putint(godziny);<br />uart_putc(':');<br />uart_putint(minuty);<br />uart_putc(':');<br />uart_putint(sekundy);<br /><br /><br />while(1){}<br /><br />}<br /><br /><br /><br /><br /><br />ISR( TIMER0_COMP_vect ){<br />    static uint8_t x;<br /><br />        x = Timer1;                             // 100Hz Timer1<br />        if (x) Timer1 = --x;<br /><br />        x = Timer2;                             // 100Hz Timer2<br />        if (x) Timer2 = --x;<br />}[/syntax]<br /><br />Wyświetla się jedynie napis &quot;Test I2C&quot;, po czym program łapie &quot;laga&quot;. Dodawałem do pętli while debug w postaci migającej diody lecz ta jest cały czas zgaszona, więc na 100% coś przy funkcjach I2C.<br /><br />i2c.c<br />[syntax=c]#include &lt;avr/io.h&gt;<br />#include &lt;avr/interrupt.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br /><br />#include &quot;i2c.h&quot;<br /><br />#define ACK 1<br />#define NACK 0<br /><br />void TWI_start( ){<br />TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWSTA);<br />while ( !(TWCR &amp; (1&lt;&lt;TWINT)) );<br />}<br /><br />void TWI_stop( ){<br />TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN)|(1&lt;&lt;TWSTO);<br />while ( !(TWCR &amp; (1&lt;&lt;TWSTO)) );<br />}<br /><br />void TWI_write( uint8_t bajt ){<br />TWDR = bajt;<br />TWCR = (1&lt;&lt;TWINT)|(1&lt;&lt;TWEN);<br />while ( !(TWCR &amp; (1&lt;&lt;TWINT)) );<br />}<br /><br />uint8_t TWI_read( uint8_t ack ){<br />TWCR = (1&lt;&lt;TWINT) | (ack&lt;&lt;TWEA) | (1&lt;&lt;TWEN);<br />while ( !(TWCR &amp; (1&lt;&lt;TWINT)) );<br />return TWDR;<br />}<br /><br />void TWI_write_buf( uint8_t SLA, uint8_t adr, uint8_t len, uint8_t *buf){<br /><br />TWI_start();<br />TWI_write(SLA);<br />TWI_write(adr);<br /><br />while (len--) TWI_write(*buf++);<br /><br />TWI_stop();<br />}<br /><br />void TWI_read_buf( uint8_t SLA, uint8_t adr, uint8_t len, uint8_t *buf){<br /><br />TWI_start();<br />TWI_write(SLA);<br />TWI_write(adr);<br />TWI_start();<br />TWI_write(SLA + 1);<br /><br />while (len--) *buf++ = TWI_read( len ? ACK : NACK );<br /><br />TWI_stop();<br />}<br /><br />uint8_t dec2bcd( uint8_t dec ){<br />return ((dec / 10) &lt;&lt; 4) | (dec % 10);<br />}<br /><br />uint8_t bcd2dec( uint8_t bcd ){<br />return ((((bcd) &gt;&gt; 4) &amp; 0x0F) * 10) + ((bcd) &amp; 0x0F);<br />}[/syntax]<br /><br />i2c.h<br />[syntax=c]#ifndef I2C_H_<br />#define I2C_H_<br /><br /><br /><br /><br /><br /><br />/*FUNKCJE GLOBALNE*/<br />void TWI_start();<br />void TWI_stop();<br />void TWI_write( uint8_t bajt );<br />uint8_t TWI_read( uint8_t ack );<br />void TWI_read_buf( uint8_t SLA, uint8_t adr, uint8_t len, uint8_t *buf);<br />void TWI_write_buf( uint8_t SLA, uint8_t adr, uint8_t len, uint8_t *buf);<br /><br />uint8_t bcd2dec( uint8_t bcd );<br /><br />#endif /* I2C_H_ */[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=2175">4MaticPL</a> — 5 lip 2014, o 10:47</p><hr />
]]></content>
</entry>
</feed>