4 Replies Latest reply on Nov 5, 2015 2:38 PM by CMata_Intel

    What is the I2C bus address used for?

    gwfong

      For a while now I have been fussing with 2 devices (Grove RGB LCD and Grove Motor Shield) attached to I2C on a Grove base shield (v1.3). I used the default bus addresses that I've seen on various posts. LCD used 0 and motor shield used GROVEMD_I2C_BUS. I'm using the latest MRAA (0.8) and UPM (0.4) library and Edison image (159.devkit).

       

      This didn't work. The LCD failed initialization during its construction. I read that the LCD was mis-documented for the Edison and that it should be 6. I tried this but it still didn't work. Looking at the UPM code, I found that GROVEMD_I2C_BUS is 15 (0x0f).

       

      I know that the device addresses are supposed to be unique, and they are in my case. I verified that. But since I didn't know what a "bus address" was used for and I was not able to find documentation about what a "bus address" is used for so I just started changing their numbers. My system finally worked after I assigned both addresses to 6.

       

      So I have a couple of questions about the bus address.

       

      1) What is it for?

       

      2) Can some elaborate on a real buildable scenario where the bus address can be different, particularly as it relates to the Edison but not necessarily. This would help my understanding.

       

      Thanks

      Gary


        • 1. Re: What is the I2C bus address used for?
          CMata_Intel

          Hi Gary,

           

          The Bus Address allows you to communicate with a specific device. You can connect to the I2C interface multiple devices, then you need to send specific information just to one device, having all the devices different addresses allows you to not send information to the other devices just to the one you want to interact. So when the same signal is received by all the devices, just the correct one will send the ACK signal and will work according to the data received.

          Take a look 7-BIT ADDRESSING [Section 9  - Page 11]

           

          Let me know if this answers your questions.

           

          Kind regards,

          Charlie

          • 2. Re: What is the I2C bus address used for?
            gwfong

            Hey Charlie,

             

            I "read" (more like scanned) that link you provided. I've read other material similar to it as well. With respect to the Edison and the UPM library I'm still confused. For example, If I look at this LCD RGB example (upm/rgb-lcd.js at master · intel-iot-devkit/upm · GitHub), I see a bus address and 2 device addresses.

             

            I'm assuming, maybe incorrectly, that the UPM library and Edison is communicating to the RGB device and LCD device using their device addresses. So I was wondering then what is the bus address used for?

             

            Also, why is it 0 in the example? And in a different forum post it said that it is incorrectly 0 and it should be 6. What dictates the correct value of the bus address? Why is 6 correct and not 0? Is there something internal to the UPM library? And then lastly, is there a relation between the value of the bus address of one device and the value of another device when both devices are connected to the same Grove base shield?

             

            Make sense?

            Thanks

            Gary

            • 3. Re: What is the I2C bus address used for?
              CMata_Intel

              Hi Gary;

               

              About the line [var myLcd = new LCD.Jhd1313m1 (0, 0x3E, 0x62);] in upm/rgb-lcd.js at master · intel-iot-devkit/upm · GitHub the 0x3E is the LCD Address, 0x62 is the RGB Address and 0 is the bus you are going to use. Take a look at upm: Jhd1313m1 Class Reference

               

              The “bus address” you are talking about is the bus for I2C that you are going to use, by default is 0.

              In the thread you posted Fix & Sample for LCD on Edison, initially there is an error with bus 6, the correct one should be 0. If you use the latest libmraa there shouldn’t be problems with this and if you use 6 or 0 with MRAA you should get the same outcome.

               

              Take a look at the Hardware Guide for the Edison Compute Module you will see in there the specifications for the I2C interface

               

              Regarding your last question, if you are talking about the bus 0 or 6, you can use the bus 0 because you are using only one interface from the Edison, the devices in the Groove Base Shield are connected to the same interface. The only relation between the devices is that they will be connected to the same interface and all of them are seeing the same SDA and SCL signals.

               

              Regards,

              Charlie

              • 4. Re: What is the I2C bus address used for?
                CMata_Intel

                Hi Gary,

                 

                We are talking about the MRAA library and the bus that is used in the library and in the examples.

                In the Hardware Guide you will see I2C1 and I2C6. The I2C1 is the one connected to the MCU (GP45 and GP47) and the I2C6 is the general purpose I2C interface (GP27 and GP28)

                 

                Regards,

                Charlie