Shop OBEX P1 Docs P2 Docs Learn Events
How do I read i2c Device ID# with basic_i2c_driver — Parallax Forums

How do I read i2c Device ID# with basic_i2c_driver

BrianProp1userBrianProp1user Posts: 3
edited 2012-12-28 03:10 in Propeller 1
I am new to i2c protocalls just started 2 days ago- to learn it...
using this basic i2c driver was fairly easy- except for trying to get the Device ID #,
like this "0xdbA1"???
so far no luck...

_______________________________________________________________________________
NXP Semiconductors UM10204
I2C-bus specification and user manual
The Device ID is read-only, hard-wired in the device and can be accessed as follows:
1. START command
2. The master sends the Reserved Device ID I2C-bus address followed by the R/W bit
set to ‘0’ (write): ‘1111 1000’.
3. The master sends the I2C-bus slave address of the slave device it needs to identify.
The LSB is a ‘Don’t care’ value. Only one device must acknowledge this byte (the one
that has the I2C-bus slave address).
4. The master sends a Re-START command.
Remark: A STOP command followed by a START command will reset the slave state
machine and the Device ID Read cannot be performed. Also, a STOP command or a
Re-START command followed by an access to another slave device will reset the
slave state machine and the Device ID Read cannot be performed.
5. The master sends the Reserved Device ID I2C-bus address followed by the R/W bit
set to ‘1’ (read): ‘1111 1001’.
6. The Device ID Read can be done, starting with the 12 manufacturer bits (first byte +
4 MSBs of the second byte), followed by the 9 part identification bits (4 LSBs of the
second byte + 5 MSBs of the third byte), and then the 3 die revision bits (3 LSBs of
the third byte).
7. The master ends the reading sequence by NACKing the last byte, thus resetting the
slave device state machine and allowing the master to send the STOP command.
Remark: The reading of the Device ID can be stopped anytime by sending a NACK
command.
If the master continues to ACK the bytes after the third byte, the slave rolls back to the first
byte and keeps sending the Device ID sequence until a NACK has been detected.
_________________________________________________________________________
this paragraph above is the steps I,m trying to figure out????______^^^^^^^^^^^^
I have no problems reading or writing to eeprom-24lc256 of coarse.
If some could help it would be great.






Comments

  • BrianProp1userBrianProp1user Posts: 3
    edited 2010-12-29 15:00
    the device would the i2c 24lc256 memory chip!!! I was thinking that you could get the id# for the
    memory chip????
    Is that possible????
  • Mike GMike G Posts: 2,702
    edited 2010-12-29 17:32
    In my limited experience the ID (address on the bus) for an I2C device is given in the datasheet. If you're looking for a unique chip identifier, you might try the manufacturer.
  • JonnyMacJonnyMac Posts: 9,108
    edited 2010-12-29 18:04
    I don't know that the 24LC256 responds to that command -- I wrote this code (uses my own i2c object) and everything comes back 1s (leads me to believe the command isn't supported).
    pub main | buf
    
      i2c.init(SCL, SDA)
      term.start(RX, TX, %0000, 115_200)
      pause(1)
    
      i2c.start
      i2c.write(%1111_1000)                                         ' Reserved Device ID
      i2c.write($A0)                                                ' Slave address of device
      i2c.start                                                     ' restart
      i2c.write(%1111_1001)                                         ' Reserved Device ID (read)
      buf := i2c.read(i2c#ACK) << 16
      buf |= i2c.read(i2c#ACK) <<  8
      buf |= i2c.read(i2c#NAK)
      i2c.stop
    
      term.tx(CLS)
      
      term.str(string("Manufacturer... "))
      term.bin(buf >> 12, 12)
      term.tx(CR)
      
      term.str(string("Device ID...... "))
      term.bin((buf >> 3) & $1FF, 9)
      term.tx(CR)
    
      term.str(string("Revision....... "))
      term.bin(buf & %111, 3)
      term.tx(CR)     
    
      repeat
        waitcnt(0)
    
  • BrianProp1userBrianProp1user Posts: 3
    edited 2010-12-29 18:16
    JonnyMac-I tried a the same code yesterday and got all 1,s back to,thought I was doing something wrong.At first I thought i was misunderstanding the steps.Maybe it,s not supported as you said???? too bad...know of any i2c memory chip that would do the same???
  • JonnyMacJonnyMac Posts: 9,108
    edited 2010-12-29 18:43
    I don't, nor can I think of a very compelling reason to need that feature. Of course, somebody thought it was a good idea or else it wouldn't be part of the specification.
  • jayasantoshjayasantosh Posts: 1
    edited 2012-12-28 02:37
    hi this address come with the i2c chip and if u want to add your own chip nummber for testing. You can also add just like any no e.g 0x3c in your driver. For testing your driver in linux pass this add under sys interface. For more information pls read linux-3.6.8\Documentation\i2c\instantiating-devices note.
  • Clive WakehamClive Wakeham Posts: 152
    edited 2012-12-28 03:10
    JonnyMac wrote: »
    I don't, nor can I think of a very compelling reason to need that feature. Of course, somebody thought it was a good idea or else it wouldn't be part of the specification.

    Maybe it is for operating systems to scan the I2C buss and then determine what exists on what address, and the device id of said device so the operating system can load the right programs to interface with the device. ie Plug n Play type feature.

    You could do it in Spin to load cogs with objects to read certain I2C devices such as ultrasonic sensors etc.
Sign In or Register to comment.