MATTHEWPENA - Viewing Profile: Topics - Netduino Forums
   
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.

MATTHEWPENA

Member Since 20 Feb 2015
Offline Last Active May 02 2015 09:04 AM
-----

Topics I've Started

ND+2 with I2C problems? Can't get any responses from slaves

17 April 2015 - 04:49 AM

Hello, I need help or direction on how to get an I2C device working with my ND+2.  I have tried many things and searched the forums for answers but nothing seems to work!  Am I doing something horibbly wrong or is there still somekind of hardware, firmware or software problems i don't know about?  is there a known good setup/combination of firmware/hardware/software/drivers that works?  it should be simple!

i've tried direct write/reads, combo write/reads...and today I tried the MultiI2C in the MFtoolbox...still no response from the I2C slave devices.

 

here is my VB code...

 

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports Microsoft.SPOT.Hardware.I2CDevice
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.Netduino
Imports Toolbox.NETMF.Hardware
Imports Toolbox.NETMF.Hardware.MultiI2C
Imports Toolbox.NETMF.Tools
 
Module Module1
    'ND+2 program ... M.Peña, April 2015
    'Firmware is 4.2.2.2, NetMF is 4.2, VB 2010 Express
 
    'trying to get the I2C to work!
 
    Sub Main()
 
        'using LSM303DLM 3-axis accelerometer, 3-axis magnetometer
        'accel: 8-bit write addr = 00110000b = 30h = 48d
        'mag  : 8-bit write addr = 00111100b = 3Ch = 60d
        'the carrier board has pull-ups on the SDA & SCL lines
 
        'whoami @ 0Fh, should read 00111100b = 3Ch = 60d
 
        'using the SDA pin toggle to wake up I2C ?
        Dim p As New Microsoft.SPOT.Hardware.OutputPort_        (SecretLabs.NETMF.Hardware.Netduino.Pins.GPIO_PIN_SDA, True)
        p.Write(False)
        System.Threading.Thread.Sleep(10)
        p.Dispose()
        p = Nothing
        System.Threading.Thread.Sleep(2000)
        Debug.Print("pulled SDA lo")
        System.Threading.Thread.Sleep(2000)
 
        'set up I2C with mag's write addr 3Ch & 100kHz clock
        Dim myiic As New MultiI2C(&H3C, 100)
        Dim retval As Int32 = -1
        Dim REGADDR() As Byte = {&HF}                'who am I reg
        Dim buff(0) As Byte                                       'buffer byte for returned data
 
        retval = myiic.WriteRead(REGADDR, buff)     'write reg addr & read into buff from reg addr
 
        'always returns 0 and 0!
        Debug.Print("ret val  = " & retval.ToString)
        Debug.Print("buff data = " & buff(0).ToString)
 
 
        System.Threading.Thread.Sleep(10000)
 
 
 
    End Sub
 
I really hope someone can direct me in the right direction...Thank You all
Matthew

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.