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.

hareega

Member Since 07 Oct 2014
Offline Last Active Nov 26 2015 03:09 PM
-----

Topics I've Started

I2C strange behavior

15 November 2015 - 02:53 AM

Greeting guys 

 

what i'm tying to do is 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:


I2C strange behavior

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:


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.