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

Need some I2C help


  • Please log in to reply
11 replies to this topic

#1 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 16 March 2012 - 05:36 AM

I'm trying to get this eeprom [PDF] working but I'm having some trouble getting it going.

This is my current test code:
I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(1, 400));

byte[] buffer = new byte[6];
I2CDevice.I2CReadTransaction read = I2CDevice.CreateReadTransaction(buffer);
eeprom .Execute(new I2CDevice.I2CTransaction[]{read}, 1000);

This code produces this result:
Posted Image



A few Thoughts:
  • The datasheet says that the control bit should be: 10100001 to do a read from the first half of the first chip on the bus, is this what is output when I create a ReadTransaction?
  • How can I figure out exactly what bits are being transferred when I do a read/write transaction?

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#2 Nathan Baker

Nathan Baker

    Member

  • Members
  • PipPip
  • 22 posts
  • LocationWisconsin

Posted 16 March 2012 - 05:40 AM

I can confirm that the chip is indeed working as he has it wired, as it worked on my arduino. We just can't seem to figure out exactly how to code this in .NET.
Posted Image

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 16 March 2012 - 05:47 AM

According to page 12 of the datasheet, you need to use the repeated start bit feature to read data from the EEPROM. Have you tried using the repeated-start-bit extension to I2C? Chris

#4 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 16 March 2012 - 05:58 AM

According to page 12 of the datasheet, you need to use the repeated start bit feature to read data from the EEPROM.

Have you tried using the repeated-start-bit extension to I2C?

Chris


I flashed the 4.1.1 Beta 1 firmware, how exactly do I use the repeated start bit? If it just involves using the 2 methods your provided (in another thread). Then yes I have with similar results, "Setup Write to ['2' (0x02]]"
.

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#5 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 16 March 2012 - 11:58 AM

I don't think you've got the slave address right. According to the datasheet, it is 1010 B0 A1 A0, so if you wired chip address inputs A1 to 0 and A0 to 1, then the slave address for block 0 is 1010001 = 0x51. The device must respond with acknowledge (ACK), NAK in your screenshot means the address is not valid (resp. there is no device with such address present on the bus).

#6 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 16 March 2012 - 01:07 PM

I don't think you've got the slave address right. According to the datasheet, it is 1010 B0 A1 A0, so if you wired chip address inputs A1 to 0 and A0 to 1, then the slave address for block 0 is 1010001 = 0x51. The device must respond with acknowledge (ACK), NAK in your screenshot means the address is not valid (resp. there is no device with such address present on the bus).


I misunderstood what you ment when I first rad that, after re-reading it, and reviewing the code it clicked.
I was able to send a successful write.
Posted Image

However when I read something is going wrong.

Posted Image

The current code is:

I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400));


I2CDevice.I2CWriteTransaction write = CreateWriteTransaction(new byte[] {0x24}, 0, 2);
byte[] buffer = new byte[6];
I2CDevice.I2CReadTransaction read = CreateReadTransaction(buffer, 0, 2);
eeprom.Execute(new I2CDevice.I2CTransaction[] { write }, 1000);
eeprom.Execute(new I2CDevice.I2CTransaction[] { read }, 1000);

I have A0 and A1 wired to GND, which makes them both 0. So my address is 0x50.

Posted Image

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#7 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 16 March 2012 - 01:31 PM

I have A0 and A1 wired to GND, which if I'm not mistaken makes them both 0.

Then the slave address (for block 0) is 1010000 = 0x50.

Attached Files



#8 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 16 March 2012 - 01:36 PM

Then the slave address (for block 0) is 1010000 = 0x50.


Indeed, see my edit above.

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 


#9 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 16 March 2012 - 01:48 PM

However when I read something is going wrong.

Try adding Thread.Sleep(5) (which is max. write cycle time) before you read the byte back.

#10 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 19 March 2012 - 12:19 PM

Out of interest, what's that software you are showing in the images (not fritzing ;))?
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"

#11 CW2

CW2

    Advanced Member

  • Members
  • PipPipPip
  • 1592 posts
  • LocationCzech Republic

Posted 19 March 2012 - 12:27 PM

Do you mean waveform captures? Those are Saleae Logic analyzer screenshots.

#12 Arron Chapman

Arron Chapman

    Advanced Member

  • Members
  • PipPipPip
  • 289 posts
  • LocationOregon, USA

Posted 19 March 2012 - 07:14 PM

Out of interest, what's that software you are showing in the images (not fritzing ;))?



Do you mean waveform captures? Those are Saleae Logic analyzer screenshots.


That would be correct, that is from my Logic. :)

When you talk EE use small words, I'm just a Software Developer :)
My Blog/Site and Everything Else

If my post helped you please consider pressing the "Like This" button in the bottom right-hand corner.

 

Oh my. So many things, so little money!!

 





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.