<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forums.obdev.at/app.php/feed/topic/6168" />

	<title>Objective Development Forums</title>
	
	<link href="https://forums.obdev.at/index.php" />
	<updated>2011-11-07T12:45:13+02:00</updated>

	<author><name><![CDATA[Objective Development Forums]]></name></author>
	<id>https://forums.obdev.at/app.php/feed/topic/6168</id>

		<entry>
		<author><name><![CDATA[ardiansyah_mrit]]></name></author>
		<updated>2011-11-07T12:45:13+02:00</updated>

		<published>2011-11-07T12:45:13+02:00</published>
		<id>https://forums.obdev.at/viewtopic.php?t=6168&amp;p=20092#p20092</id>
		<link href="https://forums.obdev.at/viewtopic.php?t=6168&amp;p=20092#p20092"/>
		<title type="html"><![CDATA[set currentAddress to send data to memori]]></title>

		
		<content type="html" xml:base="https://forums.obdev.at/viewtopic.php?t=6168&amp;p=20092#p20092"><![CDATA[
i need help, i has can to read data from eeprom in my pc...<br />but i can't to write data to eeprom from my pc, i think the currentAddress variable in usbFunctionSetup() doesn't get data buffer from my pc,<br />it just get data from it initial in usbFuctionSetup().<br /><br />how to set <em class="text-italics">currentAddress</em> in usbFunctionSetup to get data from PC ??<br /><br />i'm using at93c46 IC for my eeprom.<br /><br /><strong class="text-strong">this is my code on micro (usbFunctionSetup):</strong><br /><div class="codebox"><p>Code: </p><pre><code>if(rq-&gt;bRequest == USBRQ_HID_SET_REPORT){<br />      int i;<br />            /* since we have only one report type, we can ignore the report-ID */<br />            at93c46_ewen();<br />          <br />         bytesRemaining = 128; //128 bit<br />            <br />         for(i=0; i&lt;bytesRemaining;i++){<br />            if(i == datanya&#91;currentAddress&#93;)<br />               currentAddress=datanya&#91;i&#93;;<br />         }<br />            return USB_NO_MSG;  /* use usbFunctionWrite() to receive data from host */<br />        }</code></pre></div><br /><br /><strong class="text-strong">this is my code on micro (usbFuctionWrite) :</strong><br /><div class="codebox"><p>Code: </p><pre><code>uchar usbFunctionWrite(uchar *data, uchar len){<br /><br />   if(bytesRemaining == 0)<br />      return 1; /* end of transfer */<br /><br />   if(len &gt; bytesRemaining)<br />      len = bytesRemaining;<br />   <br />   if(test){ <br />      <br />      int i;<br />      for(i = 0; i &lt; len; i++){      <br />            if(currentAddress == i)<br />               at93c46_write(i, data&#91;0&#93;);                  <br />      }<br />   } <br /><br />   currentAddress += len;<br />   bytesRemaining -= len; // bytes = 0<br />   return bytesRemaining == 0;<br />}<br /></code></pre></div><br /><br /><strong class="text-strong">and this is my code on PC/Host with .C :</strong><br /><div class="codebox"><p>Code: </p><pre><code>int pos,i;<br />        int buflen = sizeof(buffer);<br />        memset(buffer, 0, sizeof(buffer));<br />         <br />        printf(&quot;Masukkan alamatnya : &quot;);<br />        scanf(&quot;%d&quot;, &amp;addr);<br />        <br />        printf(&quot;Masukkan Nilai : &quot;);<br />        scanf(&quot;%d&quot;, &amp;pos);<br />       <br />        buflen = addr;<br />        <br />        for(i=0; i&lt; 129 ;i++){<br />         if(i == addr)<br />            buffer&#91;addr&#93; = pos;<br />      }<br />        hexWrite(buffer,  buflen);//writing to memori method</code></pre></div><br /><br />best reagard<br />thanks be for.<p>Statistics: Posted by <a href="https://forums.obdev.at/memberlist.php?mode=viewprofile&amp;u=5842">ardiansyah_mrit</a> — Mon Nov 07, 2011 12:45 pm</p><hr />
]]></content>
	</entry>
	</feed>
