8 Replies Latest reply on Oct 12, 2017 1:23 PM by DanMadill

    Change I2C Baud Rate

    DanMadill

      Hello,

       

      What is required to change the I2C baud rate? Is the kernel compiled with support for changing the baud rate or does the kernel have to be rebuilt? What is the baud rate currently used for the BMM150 Magnetometer and MS5611 Barometer I2C port (port 2)?

       

      Dan

        • 1. Re: Change I2C Baud Rate
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hello Dan,

          Thank you for your interest in the Intel® Aero Compute Board.

          I’ll be needing more time to find an answer to your questions.

          As soon as I have information that I think you may find relevant, I’ll post it here.

          Thank you for your patience.

          Have a nice day.

          Regards,
          Andres V.

          • 2. Re: Change I2C Baud Rate
            DanMadill

            Thank you Andres.

             

            Regards,

            Dan

            • 3. Re: Change I2C Baud Rate
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hello Dan,

              The information that is currently available regarding I2C communication is found here https://github.com/intel-aero/meta-intel-aero/wiki/90-(References)-Flight-Controller-and-Compute-Board:-Sensors-GPIOs-LEDs-CAN-bus.

              Additionally, in order to provide the adequate assistance, could you please share more information regarding your project? Perhaps provide a little bit more information about what you are trying to achieve and why you need to know more about the sensor I2C baud rate and how to modify it.  

              I’ll be waiting for your response.

              Regards,
              Andres V.

              • 4. Re: Change I2C Baud Rate
                DanMadill

                Hello Andres,

                 

                I was already aware of the information on the site you referenced. In fact, I've already been talking to the I2C-based sensors. What I've noticed is that reading the BMM150 magnetometer takes about 900 microseconds. Now from what I can see from the diagram there are two devices on that I2C bus - the BMM150 magnetometer and the MS5611 barometer sensor. The BMM150 supports standard mode (100 kHz) and fast mode (400 kHz), while the MS5611 supports up to 20 MHz. Hence, it should be possible, assuming there are no other devices attached to I2C port 2, to use 400 kHz I2C communications. Reading the magnetometer means writing one byte for the slave address/read command and then reading 8 bytes of data, which can be done in a single ioctl(I2C_RDWR) call, which is 9 bytes transferred overall. Given control bits, it is approximately 9 bits per byte, or 9 * 9 = 81 bits. This transfer should then take approximately 81 / 400 kHz = 203 microseconds plus overhead. If 100 kHz I2C is being used it would take approximately 81 / 100 kHz = 810 microseconds plus overhead. Given that it seems to be taking around 900 microseconds, based on experiments, I was assuming that the I2C may be configured for 100 kHz instead of 400 kHz and was hoping to speed it up by switching to fast mode (400 kHz). So that's my immediate application.

                 

                While I'm not sure if I2C from the Intel Atom is exposed on any of the Intel Compute connectors, I'm also curious if there are generic ways to control the I2C baud rate in Linux because so far it looks to me like many systems preconfigure their I2C baud rates in the device tree or when the I2C driver is loaded. With SPI, the spidev driver allows you to switch baud rates with every transaction. Not sure why I2C doesn't seem to allow that.

                 

                Regards,

                Dan

                • 5. Re: Change I2C Baud Rate
                  Intel Corporation
                  This message was posted on behalf of Intel Corporation

                  Hello Dan,

                  Setting the frequency of the I2C controller is not possible because the respective userspace API in Linux does not exist. The alternative involves building a custom kernel (please keep in mind that custom kernels are out of the scope of this technical support team) with the I/O subsystem enabled and use the available sensor drivers.

                  The default frequency is 400 kHz, not 100 kHz. The mismatch may be due to the fact that the time measurement must be done with the controller turned off when returning the userspace in the 4.4 kernel (which takes approximately 250 us).

                  You may be interested in checking this drivers in userspace on the ArduPilot implementation:
                  https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Compass/AP_Compass_BMM150.cpp 
                  https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_Baro/AP_Baro_MS5611.cpp 

                  If you have any update or another question, don’t hesitate to contact us.

                  Have a nice day.

                  Regards,
                  Andres V.

                  1 of 1 people found this helpful
                  • 6. Re: Change I2C Baud Rate
                    DanMadill

                    Hello Andres,

                     

                    Thank you for information. It is good to know that the default I2C rate is 400 kHz.

                     

                    I'm currently measuring time using clock_gettime(CLOCK_REALTIME, &clock_time). Is there a more efficient means of measuring time accurately, without the 250 us overhead? I have read the processor clock directly on other platforms, but they were single core, not quad core, so there would be issues trying that on the Intel Compute board.

                     

                    Regards,

                    Dan

                    • 7. Re: Change I2C Baud Rate
                      Intel Corporation
                      This message was posted on behalf of Intel Corporation

                      Hello Dan,

                      That inquiry is more Linux-related than Aero-related, and as such, out of the scope of this technical support team.

                      Perhaps you may be interested in checking this FAQ: http://juliusdavies.ca/posix_clocks/clock_realtime_linux_faq.html. It seems to imply that clock_gettime() can be used for single-core and quad-core systems. Although, I couldn’t find any information regarding how to use the clock_gettime function without overhead. 

                      Regards,
                      Andres V.

                      • 8. Re: Change I2C Baud Rate
                        DanMadill

                        Hello Andres,

                         

                        All right. Fair enough. Thanks again.

                         

                        Regards,

                        Dan