Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

I2C strange behavior


  • Please log in to reply
No replies to this topic

#1 hareega

hareega

    New Member

  • Members
  • Pip
  • 4 posts

Posted 15 November 2015 - 02:51 AM

Greeting guys 

 

what i'm tying to do is to sort of pinging a device for a three times

and i want to know why the I2C execution return 0 in the first time but not in the rest.

            var config = new I2CDevice.Configuration(83, 100);
            var I2C_Bus = new I2CDevice(config);

            I2CDevice.I2CTransaction[] transactions;
            transactions = new I2CDevice.I2CTransaction[2];

            transactions[0] = I2CDevice.CreateWriteTransaction(new byte[1]);
            transactions[1] = I2CDevice.CreateReadTransaction(new byte[1]);

            for (var i = 0; i < 3; i++)
            {
                int result = I2C_Bus.Execute(transactions, 1000);

                if (result > 0)
                {
                    Debug.Print("found");
                }
                else
                {
                    Debug.Print("not found");
                }
            }

This is the debug result i get :

not found
found
found

any ideas?  :huh:






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.