<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis MicrocontrollersのトピックCreating an i2c address scanner</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350513#M17282</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking to write some code that will scan the i2c bus for devices. From what I understand from existing i2cspy implementations, you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;send a start condition&lt;/LI&gt;&lt;LI&gt;send an address over the bus&lt;/LI&gt;&lt;LI&gt;check to see if an ack was received&lt;/LI&gt;&lt;LI&gt;send a stop condition&lt;/LI&gt;&lt;LI&gt;repeat&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm still learning the libraries provided by processor expert, and attempted to do this with the select slave method and receive block, so it would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; LDD_TDeviceData iic_handle = CI2C1_Init( &amp;amp;flags );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; for( byte addr = 0x10; addr &amp;lt; 0x70; addr++ ) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("S: %02x ", addr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( CI2C1_SelectSlaveDevice( iic_handle, LDD_I2C_ADDRTYPE_7BITS, addr ) != ERR_OK );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CI2C1_MasterSendBlock( iic_handle, NULL, 0, LDD_I2C_SEND_STOP );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( flag == 0 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Where the flags variable is set by an interrupt event, and would be checked later to see what kind of event it was. I also tried this using the non-LDD "Internal I2C" device, and found that it had a nice event for SCL Timeout, which doesn't appear to be present in the LDD version.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Has anyone tried doing something like this before? I'm going to see if I can access more fine grained control over the device by looking at the generated code and the Technical manual for the device family, but wanted to know if anyone else had tried this first.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Accidentally posted half the message instead of the whole thing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 18 Nov 2014 16:37:16 GMT</pubDate>
    <dc:creator>allgood38</dc:creator>
    <dc:date>2014-11-18T16:37:16Z</dc:date>
    <item>
      <title>Creating an i2c address scanner</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350513#M17282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm looking to write some code that will scan the i2c bus for devices. From what I understand from existing i2cspy implementations, you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;send a start condition&lt;/LI&gt;&lt;LI&gt;send an address over the bus&lt;/LI&gt;&lt;LI&gt;check to see if an ack was received&lt;/LI&gt;&lt;LI&gt;send a stop condition&lt;/LI&gt;&lt;LI&gt;repeat&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I'm still learning the libraries provided by processor expert, and attempted to do this with the select slave method and receive block, so it would look like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; LDD_TDeviceData iic_handle = CI2C1_Init( &amp;amp;flags );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; for( byte addr = 0x10; addr &amp;lt; 0x70; addr++ ) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("S: %02x ", addr);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( CI2C1_SelectSlaveDevice( iic_handle, LDD_I2C_ADDRTYPE_7BITS, addr ) != ERR_OK );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CI2C1_MasterSendBlock( iic_handle, NULL, 0, LDD_I2C_SEND_STOP );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while( flag == 0 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // ...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Where the flags variable is set by an interrupt event, and would be checked later to see what kind of event it was. I also tried this using the non-LDD "Internal I2C" device, and found that it had a nice event for SCL Timeout, which doesn't appear to be present in the LDD version.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Has anyone tried doing something like this before? I'm going to see if I can access more fine grained control over the device by looking at the generated code and the Technical manual for the device family, but wanted to know if anyone else had tried this first.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;SPAN style="font-family: arial,helvetica,sans-serif;"&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Accidentally posted half the message instead of the whole thing&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 16:37:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350513#M17282</guid>
      <dc:creator>allgood38</dc:creator>
      <dc:date>2014-11-18T16:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an i2c address scanner</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350514#M17283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using that I2CSpy to scan the bus for 'unknown' devices, or to verify the I2C device address.&lt;/P&gt;&lt;P&gt;&lt;A href="http://mcuoneclipse.com/2012/12/23/csi-crime-scene-investigation-with-i2cspy-and-freedom-board/" title="http://mcuoneclipse.com/2012/12/23/csi-crime-scene-investigation-with-i2cspy-and-freedom-board/"&gt;http://mcuoneclipse.com/2012/12/23/csi-crime-scene-investigation-with-i2cspy-and-freedom-board/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 17:19:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350514#M17283</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-11-18T17:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating an i2c address scanner</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350515#M17284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Erich,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for the reply, and that's a really great post!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So after a little searching through your repo, I found this snippet:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/ErichStyger/McuOnEclipse_PEx/blob/master/Drivers/sw/GenericI2C.drv#L1086" title="https://github.com/ErichStyger/McuOnEclipse_PEx/blob/master/Drivers/sw/GenericI2C.drv#L1086"&gt;https://github.com/ErichStyger/McuOnEclipse_PEx/blob/master/Drivers/sw/GenericI2C.drv#L1086&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which seems to be responsible for the actual check on an address. So from what I can tell, it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;calls select slave on the address&lt;/LI&gt;&lt;LI&gt;sets up a timer&lt;/LI&gt;&lt;LI&gt;Lopps until either the timer to expires or the device to ACKs&lt;/LI&gt;&lt;LI&gt;Checks the error mask to see if there was no ACK&lt;/LI&gt;&lt;LI&gt;Manually sends a stop condition&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this roughly what is happening? I haven't looked at the events file yet, its a little difficult to navigate the (*.drv) file with the PEx markup. Of course it is really cool that the PEx beans are able to make the code as flexible as it is.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2014 20:43:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350515#M17284</guid>
      <dc:creator>allgood38</dc:creator>
      <dc:date>2014-11-18T20:43:49Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Creating an i2c address scanner</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350516#M17285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Stephen,&lt;/P&gt;&lt;P&gt;Yes, that's what's happening.&lt;/P&gt;&lt;P&gt;I have attached you an example project (with the generated sources) for the FRDM-KL25Z. The function is in ScanDevices() which calls I2C2_ScanDevice().&lt;/P&gt;&lt;P&gt;The project is on GitHub too: &lt;A href="https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_I2CSpy" title="https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/FRDM-KL25Z/Freedom_I2CSpy"&gt;mcuoneclipse/Examples/FRDM-KL25Z/Freedom_I2CSpy at master · ErichStyger/mcuoneclipse · GitHub&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Erich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Nov 2014 06:41:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/Creating-an-i2c-address-scanner/m-p/350516#M17285</guid>
      <dc:creator>BlackNight</dc:creator>
      <dc:date>2014-11-19T06:41:18Z</dc:date>
    </item>
  </channel>
</rss>

