Shop OBEX P1 Docs P2 Docs Learn Events
Help using I2C protocol — Parallax Forums

Help using I2C protocol

Wissam Ch.Wissam Ch. Posts: 36
edited 2007-11-03 17:18 in General Discussion
Hi ,
Ive read the documentation about I2c protocl in Gunther's Book "Programming the SX microcontroller" , but i could not understand technically how to assign an address for each device connected to the bus.

suppose for example i have DS-1302 and DS-1620 connected to the I2c bus .
How to assign addresses to these chips and communicate with them.

note : Iam using Assembly for coding.

Regards.
·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-02 21:35
    I2C chips have pre-assigned addresses. Look at the datasheet for the device for the specific address. Many devices will let you set a portion of the address via extra pins on the device. Again, check the datasheet for details.
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2007-11-02 21:51
    Thanks Mike for the tip .
    Iam not that expert in reading data sheets , i just started recently programming SX m.c .

    could you please guide me where to look exactly.

    i attached a data sheet file for the DS1302.

    Regards.
  • JonnyMacJonnyMac Posts: 9,216
    edited 2007-11-02 22:53
    The DS1302 is an SPI device (and is not I2C compatible); for that matter, so is the DS1620. You can share the clock and data pins but will need separate RST lines for each so that only one can be on the buss at the same time. There is SX/B code in the SX-Key help file; it will help you get started, even though you're using assembly.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-11-02 23:31
    SPI is a different protocol that requires at least 3 I/O pins, possibly 4. There's no addressing needed because each chip requires a separate select line (low true). SPI is not as standardized as I2C and each device may have different details about how data is transmitted to the device and you really must become familiar with the datasheet of each device. For example, some devices use separate receive and transmit data lines (and all have a clock and the select line) and transmit status back to the controller at the same time that data is being received. Some devices expect 11 bits to be sent / received on every data transfer while most expect 8 bits.
  • Wissam Ch.Wissam Ch. Posts: 36
    edited 2007-11-03 17:18
    Thanks gentlemen for the feedack .
    I think now the situation is clearer to me.
Sign In or Register to comment.