<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>I2C Read Problem</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17981/i2c-read-problem</link><description> Hello, 
 I am trying to write a Set of Bit Bang I2C Functions to communicate with a SRF08 Range Finder. I found some code by Grant Beattie for the HC11 and have addapted it for the 89LPC932. Now I have the Start, stop, and Write Byte functions working</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/145905?ContentTypeID=1</link><pubDate>Wed, 08 Sep 2004 07:17:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8a5b7e2c-1543-42dd-b6c0-c446cf4189da</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;but I do not receive any data back from case 58:&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;    // no ACK for data byte
    case 0x58&lt;/pre&gt;
&lt;br /&gt;
why would you, if the other and does not ACK, how would the byte be there&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/143986?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 16:10:26 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5b0aacfe-7fcc-4348-8353-0fcb731a0632</guid><dc:creator>Kenny Walling</dc:creator><description>&lt;p&gt;One more question if you are still there Erik.  I have  the code architect functions working in that they go to all of the correct interrupts, but I do not receive any data back from case 58:  my I2Dat value is always zero.  Just wondering if you have seen this before.  This is my Init routine.&lt;br /&gt;
&lt;pre&gt;
void i2c_init(
  unsigned char address,  // The 7-bit I2C address to use
  bit generalcall         // 1 = respond to general call, 0 = ignore
                          // general call
  )
{
  // set pins to open-drain
  P1M1 |= 0x0C;
  P1M2 |= 0x0C;

  // configure I2C address
  I2ADR = 0x00;
  //I2ADR = address &amp;lt;&amp;lt; 1;
  //if (generalcall)
  //{
  //  I2ADR |= 0x01;
  //} // if

  // configure internal SCL generator
  //Page 79 of the user manual gives these values for close to 400Kbit/S
  //SCLH (SCL Duty Cycle Register High Byte)
  I2SCLH =0x08;
  //SCLL (SCL Duty Cycle Reister Low Byte)
  I2SCLL =0x07;

  // configure I2C interface
  // use internal SCL generator
  I2CON = 0x44;

  // set interrupt priority to 0
  IP1 &amp;amp;= ~0x01;
  IP1H &amp;amp;= ~0x01;

  // initial status
  mi2cstatus = I2C_IDLE;

  // enable interrupt

  EI2C = 1;
  EA=1;
} // i2c_init
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/141416?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 14:55:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:9fcc4353-c955-4a46-8493-8d56e01c5e2d</guid><dc:creator>Kenny Walling</dc:creator><description>&lt;p&gt;Hey Erik,&lt;br /&gt;
   Looks Like it was a bad Emulator the SCL pin was always high.  Put in a New Emulator and it is starting to work.  I think It is good now.  Thank You for all of your help.&lt;br /&gt;
&lt;br /&gt;
Kenny&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/137913?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 13:20:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bbdf4be2-ea82-4c37-be30-f96321d9342a</guid><dc:creator>Kenny Walling</dc:creator><description>&lt;p&gt;Pin Configs are OK and I have 1.5k pull ups.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/134436?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 12:43:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e4fc1a3f-ea38-4b99-950c-2f44a5784111</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;in &lt;b&gt;my&lt;/b&gt; i2c_init&lt;/i&gt;&lt;br /&gt;
There is an IICinit in the codearchitect, make sure nothing (eg pin configurations) is lost from there.  Also, do you have pullup resisttors on the two lines?&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/122496?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 12:41:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7705a894-f2ee-4d30-a409-bf5729e3423a</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;I am trying to use the Code architect code. Is this the way you would use the functions. I send a transmit and try to wait for the interrupt to take care of the rest. I have set EI2C =1 and EA =1 in my i2c_init, which I call.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/111057?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 11:25:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:45481926-c1f3-4db1-ac42-c4e01a03d3e1</guid><dc:creator>Kenny Walling</dc:creator><description>&lt;p&gt;Hey Eric,&lt;br /&gt;
  I am trying to use the Code architect code.  Is this the way you would use the functions.  I send a transmit and try to wait for the interrupt to take care of the rest.  I have set EI2C =1 and EA =1 in my i2c_init, which I call.&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
int read_SRF08(int device, int reg)
{
	unsigned char databyte;

	 i2c_transmit(SRF08_1);
	 printf(&amp;quot;\ninto the i2cok loop %d\n&amp;quot;,SI);
	 while (i2c_getstatus() &amp;amp; I2C_BUSY) printf(&amp;quot;\nSI=%d\n&amp;quot;,SI);

	 printf(&amp;quot;out of the i2cok loop\n&amp;quot;);
 		//databyte=i2c_recieve();
	return databyte;
 }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/96557?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 10:40:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e4c890c5-1667-41fc-a431-9d050e6d9b6a</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;I could not get the internal interrupt to work. &lt;/i&gt;&lt;br /&gt;
You probably do not have it enabled.&lt;br /&gt;
&lt;i&gt;If you have done this succesfully I would like to see your code.&lt;/i&gt;&lt;br /&gt;
Use codearchitect and you will see what I have.&lt;br /&gt;
&lt;br /&gt;
There are some &amp;#39;small pieces&amp;#39; that are easy to &amp;#39;forget&amp;#39; or &amp;#39;kill&amp;#39;&lt;br /&gt;
a) the initializizations must be called&lt;br /&gt;
b) the pin config settings should not be overwritten later (I goofed on that one)&lt;br /&gt;
c) the interrupt enable bits should not be overwritten later.&lt;br /&gt;
&lt;br /&gt;
Check the above.&lt;br /&gt;
&lt;br /&gt;
Erik&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/72706?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 10:13:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d56c9b1f-567b-4937-87ed-e1151a7865a7</guid><dc:creator>Kenny Walling</dc:creator><description>&lt;p&gt;I have also tried that with no luck.  I could not get the internal interrupt to work.  If you have done this succesfully I would like to see your code. Thank You.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I2C Read Problem</title><link>https://community.arm.com/thread/42733?ContentTypeID=1</link><pubDate>Tue, 07 Sep 2004 08:53:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:35f2f330-dff9-4d65-90fa-1907b414faaa</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;&lt;i&gt;Bit Bang I2C ... addapted it for the 89LPC932&lt;/i&gt;&lt;br /&gt;
Why on earth have you done that?  The 932 has hardware IIC.&lt;br /&gt;
&lt;br /&gt;
You do not even have to create the code, codearchitect free from &lt;a href="http://www.esacademy.com" target="_blank"&gt;http://www.esacademy.com&lt;/a&gt; will do that for you.&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>