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

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2014-01-31T20:20:18+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=4&amp;t=5767&amp;mode</id>
<entry>
<author><name><![CDATA[kaktus28]]></name></author>
<updated>2014-01-31T20:20:18+01:00</updated>
<published>2014-01-31T20:20:18+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=5767&amp;p=67677#p67677</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=5767&amp;p=67677#p67677"/>
<title type="html"><![CDATA[Czujnik TCN75A+ AVR]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=5767&amp;p=67677#p67677"><![CDATA[
Witam próbuje odczytać temperature z  czujnika TCN75A po i2c wykorzystując biblioteki i2c Pana Mirka i nie działa:<br />[syntax=c]int main(void)<br />{   <br /><br />        usart_ini();<br />        sei(); <br />uint8_t x=0x60;// dokładnośc 0,0625<br />TWI_write_buf(0xA0,0x01,1, &amp;x);//adress urządzenia-0xa0,adres rejestru-0x01 (config), jeden bajt,wartość<br />uint8_t buf&#91;2&#93;={0,0,0};<br />TWI_read_buf(0xa0,0x00,0x03,buf);//adress urządzenia-0xa0,,adress rejestru dla temperatury,3bajty, bufor<br />Tx_buf&#91;0&#93;=buf&#91;0&#93;;<br />        Tx_buf&#91;1&#93;=buf&#91;1&#93;;<br />Tx_buf&#91;2&#93;=buf&#91;2&#93;;<br />    while(1)<br />    {<br /><br />        Transmition(); <br />    }[/syntax]<br /><br />Tx_buf jest odsyłane przez UART<br /><br />[syntax=c]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(0x00);//starsz bajt<br />TWI_write(adr);<br />while(len--) TWI_write(*buf++);<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(0x00);<br />TWI_write(adr);<br />TWI_start();<br />TWI_write(SLA+1);//0?<br />while(len--) *buf++=TWI_read(len?ACK:NACK);<br />TWI_stop();<br /><br /><br />}[/syntax]<br /><br />Co robie nie tak?<br /><br /><span style="color: #FF0000">Kod wklejamy przy pomocy syntax=c - Różowy J.</span><p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1162">kaktus28</a> — 31 sty 2014, o 20:20</p><hr />
]]></content>
</entry>
</feed>