Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 9:30 am

Hi,

I have an IMU (part# LSM9DS1) that I am trying to connect to I2C0 of a CM3L. When I do i2cdetect -y 0, I see that my IMU is connected to address 1e (accelerometer) and 6b (gyroscope). When I do raspi-gpio get 0-1, it shows the pins functionality as SDA0 and SCL0 respectively. Also, this only works if I include the following line in /boot/config.txt:

Code: Select all

dtparam=i2c0=on
Then I run my python code to read the sensor's readings:

Code: Select all

#!/usr/bin/env python3
# coding: utf-8

import ctypes

import threading
import sys
import time
import sched
import datetime
from datetime import datetime

from ctypes import *
{ "__CURSOR" : "s=f80b63610a5f46a5a775ef80a3624a09;i=7956;b=1800441909b74ff7a2edd5e36aefb907;m=cf2de5bc;t=55bd13336f4b1;x=3c80b7f7f096674c", "__REALTIME_TIMESTAMP" : "1508328949085361", "__MONOTONIC_TIMESTAMP" : "3475891644", "_BOOT_ID" : "1800441909b74ff7a2edd5e36aefb907", "_SYSTEMD_CGROUP" : "/user.slice/user-1000.slice/session-c1.scope", "_SYSTEMD_SESSION" : "c1", "_SYSTEMD_OWNER_UID" : "1000", "_SYSTEMD_UNIT" :
        "session-c1.scope", "_SYSTEMD_SLICE" : "user-1000.slice", "_SYSTEMD_USER_SLICE" : "-.slice", "_SYSTEMD_INVOCATION_ID" : "3e7e567985cc4ca1899bbe3617a8fcab", "_MACHINE_ID" : "2da8dbfa7f954d6a9797343a72038f2e", "_HOSTNAME" : "raspberrypi", "PRIORITY" : "6", "_UID" : "0", "_GID" : "0", "_CAP_EFFECTIVE" : "3fffffffff", "_TRANSPORT" : "syslog", "SYSLOG_FACILITY" : "10", "SYSLOG_IDENTIFIER" : "sudo", "_COMM" : "sudo",
        "_EXE" : "/usr/bin/sudo", "MESSAGE" : "pam_unix(sudo:session): session opened for user root by (uid=0)", "_PID" : "5032", "_CMDLINE" : "sudo journalctl -f -o json", "_SOURCE_REALTIME_TIMESTAMP" : "1508328949085270" }


LSMSENSOR_COUNT = 0
path = "/home/pi/python_scripts/LSM9DS1_RaspberryPi_Library-master/lib/liblsm9ds1cwrapper.so"
lib = cdll.LoadLibrary(path)

lib.lsm9ds1_create.argtypes = []
lib.lsm9ds1_create.restype = c_void_p

lib.lsm9ds1_begin.argtypes = [c_void_p]
lib.lsm9ds1_begin.restype = None

lib.lsm9ds1_calibrate.argtypes = [c_void_p]
lib.lsm9ds1_calibrate.restype = None

lib.lsm9ds1_gyroAvailable.argtypes = [c_void_p]
lib.lsm9ds1_gyroAvailable.restype = c_int
lib.lsm9ds1_accelAvailable.argtypes = [c_void_p]
lib.lsm9ds1_accelAvailable.restype = c_int
lib.lsm9ds1_magAvailable.argtypes = [c_void_p]
lib.lsm9ds1_magAvailable.restype = c_int

lib.lsm9ds1_readGyro.argtypes = [c_void_p]
lib.lsm9ds1_readGyro.restype = c_int
lib.lsm9ds1_readAccel.argtypes = [c_void_p]
lib.lsm9ds1_readAccel.restype = c_int
lib.lsm9ds1_readMag.argtypes = [c_void_p]
lib.lsm9ds1_readMag.restype = c_int

lib.lsm9ds1_getGyroX.argtypes = [c_void_p]
lib.lsm9ds1_getGyroX.restype = c_float
lib.lsm9ds1_getGyroY.argtypes = [c_void_p]
lib.lsm9ds1_getGyroY.restype = c_float
lib.lsm9ds1_getGyroZ.argtypes = [c_void_p]
lib.lsm9ds1_getGyroZ.restype = c_float

lib.lsm9ds1_getAccelX.argtypes = [c_void_p]
lib.lsm9ds1_getAccelX.restype = c_float
lib.lsm9ds1_getAccelY.argtypes = [c_void_p]
lib.lsm9ds1_getAccelY.restype = c_float
lib.lsm9ds1_getAccelZ.argtypes = [c_void_p]
lib.lsm9ds1_getAccelZ.restype = c_float

lib.lsm9ds1_calcGyro.argtypes = [c_void_p, c_float]
lib.lsm9ds1_calcGyro.restype = c_float
lib.lsm9ds1_calcAccel.argtypes = [c_void_p, c_float]
lib.lsm9ds1_calcAccel.restype = c_float


if __name__ == "__main__":
    imu = lib.lsm9ds1_create()
    print("IMU instance created")
    lib.lsm9ds1_begin(imu)
    print("Comm initiated")
    if lib.lsm9ds1_begin(imu) == 0:
        print("Failed to communicate with LSM9DS1.")
        quit()
    print("Calibrating IMU")
    lib.lsm9ds1_calibrate(imu)
    print("Calibration Complete")

    while True:
        while lib.lsm9ds1_gyroAvailable(imu) == 0:
            pass
        lib.lsm9ds1_readGyro(imu)
        while lib.lsm9ds1_accelAvailable(imu) == 0:
            pass
        lib.lsm9ds1_readAccel(imu)
        while lib.lsm9ds1_magAvailable(imu) == 0:
            pass
        lib.lsm9ds1_readMag(imu)

        print("Get Gyro")
        gx = lib.lsm9ds1_getGyroX(imu)
        gy = lib.lsm9ds1_getGyroY(imu)
        gz = lib.lsm9ds1_getGyroZ(imu)

        print("Get Accel")
        ax = lib.lsm9ds1_getAccelX(imu)
        ay = lib.lsm9ds1_getAccelY(imu)
        az = lib.lsm9ds1_getAccelZ(imu)

        print("Calculate Gyro")
        cgx = lib.lsm9ds1_calcGyro(imu, gx)
        cgy = lib.lsm9ds1_calcGyro(imu, gy)
        cgz = lib.lsm9ds1_calcGyro(imu, gz)

        print("Calculate Accel")
        cax = lib.lsm9ds1_calcAccel(imu, ax)*9.81
        cay = lib.lsm9ds1_calcAccel(imu, ay)*9.81
        caz = lib.lsm9ds1_calcAccel(imu, az)*9.81


        print("Accel: %f, %f, %f " % (cax, cay, caz))
        print("Gyro: %f, %f, %f " % (cgx, cgy, cgz))

        time.sleep(1)

and I get this error:

Code: Select all

IMU instance created
Comm initiated
Calibrating IMU
Calibration Complete
terminate called after throwing an instance of 'int'
Aborted
I am using a C++ library I found here: https://github.com/akimach/LSM9DS1_RaspberryPi_Library
Since my test code is in Python there is a C wrapper shared object called "liblsm9ds1cwrapper.so" which I am using to make my code to work in Python. I feel there is nothing wrong with my code because I run the same python code on I2C1, and it works perfectly fine. I also know for a fact that, I get the above error when I have not made any one of the I2C connections i.e. if I dont connect the SCL or the SDA line. Otherwise, i2C-1 is perfectly fine. This could also mean that I2C-0 is telling me that no device is present. But then why is my device getting recognised when I do "i2cdetect -y 0"? This is something to do with the funny business that's happening with I2C0. I even tried doing what PhilE suggested here: viewtopic.php?t=172527 i.e. adding "dtoverlay=i2c-gpio,i2c_gpio_sda=0,i2c_gpio_scl=1" in /boot/config.txt. I still can't get the I2C0 to work. Can someone help me please?

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 10:07 am

Update: The OS that I am using is Raspbian Stretch Lite (headless), the latest one available on raspberrypi.org right now. I did the following:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install rpi-update
sudo rpi-update
Still can't get my code to work on I2C-0.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5660
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 10:22 am

Obvious questions first - do you have any I2C pull-up resistors?
The CM deliberately makes no assumptions about how you wish to use the GPIOs, so there are almost no pull-up/down resistors on the lines. For using i2c-0 with the camera or display, they are on the camera/display connector side of the jumper wires you add. For any other use of I2C you need to add your own pull-ups (typically 1k8 to 3v3 on each of SDA and SCL).
If you're solely using the internal pull-ups of the SoC then I2C comms will be intermittent.
The fact that you get the same error when SDA/SCL are disconnected would lead me to suspect a wiring type issue first. i2cdetect does one single I2C write and checks for an ACK. Your library is needing to do multiple reads, so pull-ups are crucial.
Sohil.Mehta wrote:
Mon Apr 23, 2018 9:30 am
This is something to do with the funny business that's happening with I2C0. I even tried doing what PhilE suggested here: viewtopic.php?t=172527 i.e. adding "dtoverlay=i2c-gpio,i2c_gpio_sda=0,i2c_gpio_scl=1" in /boot/config.txt. I still can't get the I2C0 to work. Can someone help me please?
As I said on the other thread, there are no restrictions on using i2c-0 on the CM3 since Feb 2017. There is a very slim chance it is linked to that, but I very much doubt it.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 10:28 am

you need to add your own pull-ups (typically 1k8 to 3v3 on each of SDA and SCL).
Exactly what I have done. Yes, I have external pull-ups of 1.8k to 3.3V on both SDA and SCL for I2C-0.
Last edited by Sohil.Mehta on Tue Apr 24, 2018 5:03 am, edited 1 time in total.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 4:12 pm

Update: Tried changing the i2c0 pins to 28 and 29 using this line in /boot/config.txt:

Code: Select all

dtoverlay=i2c0-bcm2708,sda0_pin=28,scl0_pin=29,pins_28_29
Still no success. Can't understand where I am going wrong.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 4:23 pm

I went to /boot/overlays. The overlays I found there are:

Code: Select all

i2c0-bcm2708.dtbo                       
i2c1-bcm2708.dtbo                       
i2c-bcm2708.dtbo                        
i2c-gpio.dtbo                           
i2c-mux.dtbo                            
i2c-pwm-pca9685a.dtbo                   
i2c-rtc.dtbo                            
i2c-rtc-gpio.dtbo                       
i2c-sensor.dtbo 
I dont see any overlay like i2c0-bcm2837.dtbo. Isn't that the processor that goes on CM3L? Could that be the problem? Also will it be okay if I use 1.5k pull up resistors and not 1.8k?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5660
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C0 not working on Compute module 3 Lite

Mon Apr 23, 2018 4:56 pm

Sohil.Mehta wrote:
Mon Apr 23, 2018 4:12 pm
Update: Tried changing the i2c0 pins to 28 and 29 using this line in /boot/config.txt:

Code: Select all

dtoverlay=i2c0-bcm2708,sda0_pin=28,scl0_pin=29,pins_28_29
Still no success. Can't understand where I am going wrong.
If you want to use it, then

Code: Select all

dtoverlay=i2c0-bcm2708,pins_28_29=1
or

Code: Select all

dtoverlay=i2c0-bcm2708,sda0_pin=28,scl0_pin=29
not both.
Sohil.Mehta wrote:
Mon Apr 23, 2018 4:23 pm
I went to /boot/overlays. The overlays I found there are:

Code: Select all

i2c0-bcm2708.dtbo                       
i2c1-bcm2708.dtbo                       
i2c-bcm2708.dtbo                        
i2c-gpio.dtbo                           
i2c-mux.dtbo                            
i2c-pwm-pca9685a.dtbo                   
i2c-rtc.dtbo                            
i2c-rtc-gpio.dtbo                       
i2c-sensor.dtbo 
I dont see any overlay like i2c0-bcm2837.dtbo. Isn't that the processor that goes on CM3L? Could that be the problem?
Use i2c0-bcm2708. It's a common core within all variants of the SoC, just the ARMs have changed.
Technically BCM2708/2709/2710 are the unpackaged silicon, and BCM2835/2836/2837 are packaged versions, but that has no real relevance outside of Broadcom.
Sohil.Mehta wrote:Also will it be okay if I use 1.5k pull up resistors and not 1.8k?
Unlikely to make any difference. Do you want GPIOs 28&29? The default would be 0&1, so I'd suggest you get things working with the default settings first before messing around with other stuff.

Based on your earlier comments it sounds like it is still hardware causing flaky I2C.
- Check your kernel and firmware versions - "uname -a" and "vcgencmd version". Some time this year would be a good start.
- Use "sudo raspi-gpio get" to confirm that ONLY 0&1 are set to SDA0 or SCL0. Mapping multiple GPIOs to the same function screws them up.
- Use something other than your current app to talk to the sensor and confirm you have reliable communications. Unfortunately you have this black box of a C++ library that is masking the true error that it is seeing.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 5:00 am

Do you want GPIOs 28&29? The default would be 0&1, so I'd suggest you get things working with the default settings first before messing around with other stuff.
I want to run it on GPIOs 0 and 1 only. I was trying to see if I could make it work on 28 and 29. It that worked, I could conclude that something is fishy about 0 and 1. But it dint work on 28 and 29 as well.
Check your kernel and firmware versions - "uname -a" and "vcgencmd version". Some time this year would be a good start.
Output of uname -a

Code: Select all

Linux raspberrypi 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux
Output of vcgencmd version

Code: Select all

Apr 16 2018 18:16:56 
Copyright (c) 2012 Broadcom
version af8084725947aa2c7314172068f79dad9be1c8b4 (clean) (release)
Output of raspi-gpio get

Code: Select all

GPIO 0: level=1 fsel=4 alt=0 func=SDA0
GPIO 1: level=1 fsel=4 alt=0 func=SCL0
GPIO 2: level=1 fsel=4 alt=0 func=SDA1
GPIO 3: level=1 fsel=4 alt=0 func=SCL1
GPIO 4: level=1 fsel=0 func=INPUT
GPIO 5: level=1 fsel=0 func=INPUT
GPIO 6: level=1 fsel=0 func=INPUT
GPIO 7: level=1 fsel=1 func=OUTPUT
GPIO 8: level=1 fsel=1 func=OUTPUT
GPIO 9: level=0 fsel=4 alt=0 func=SPI0_MISO
GPIO 10: level=0 fsel=4 alt=0 func=SPI0_MOSI
GPIO 11: level=0 fsel=4 alt=0 func=SPI0_SCLK
GPIO 12: level=0 fsel=0 func=INPUT
GPIO 13: level=0 fsel=0 func=INPUT
GPIO 14: level=1 fsel=2 alt=5 func=TXD1
GPIO 15: level=1 fsel=2 alt=5 func=RXD1
GPIO 16: level=0 fsel=0 func=INPUT
GPIO 17: level=0 fsel=0 func=INPUT
GPIO 18: level=0 fsel=0 func=INPUT
GPIO 19: level=0 fsel=0 func=INPUT
GPIO 20: level=0 fsel=0 func=INPUT
GPIO 21: level=0 fsel=0 func=INPUT
GPIO 22: level=0 fsel=0 func=INPUT
GPIO 23: level=0 fsel=0 func=INPUT
GPIO 24: level=1 fsel=0 func=INPUT
GPIO 25: level=0 fsel=0 func=INPUT
GPIO 26: level=0 fsel=0 func=INPUT
GPIO 27: level=0 fsel=0 func=INPUT
BANK1 (GPIO 28 to 45):
GPIO 28: level=0 fsel=0 func=INPUT
GPIO 29: level=0 fsel=0 func=INPUT
GPIO 30: level=0 fsel=0 func=INPUT
GPIO 31: level=0 fsel=0 func=INPUT
GPIO 32: level=0 fsel=0 func=INPUT
GPIO 33: level=0 fsel=0 func=INPUT
GPIO 34: level=1 fsel=0 func=INPUT
GPIO 35: level=1 fsel=0 func=INPUT
GPIO 36: level=0 fsel=6 alt=2 func=TXD0
GPIO 37: level=1 fsel=6 alt=2 func=RXD0
GPIO 38: level=0 fsel=0 func=INPUT
GPIO 39: level=0 fsel=0 func=INPUT
GPIO 40: level=0 fsel=0 func=INPUT
GPIO 41: level=0 fsel=0 func=INPUT
GPIO 42: level=0 fsel=0 func=INPUT
GPIO 43: level=0 fsel=0 func=INPUT
GPIO 44: level=0 fsel=0 func=INPUT
GPIO 45: level=0 fsel=0 func=INPUT
BANK2 (GPIO 46 to 53):
GPIO 46: level=1 fsel=0 func=INPUT
GPIO 47: level=1 fsel=1 func=OUTPUT
GPIO 48: level=0 fsel=4 alt=0 func=SD0_CLK
GPIO 49: level=1 fsel=4 alt=0 func=SD0_CMD
GPIO 50: level=1 fsel=4 alt=0 func=SD0_DAT0
GPIO 51: level=1 fsel=4 alt=0 func=SD0_DAT1
GPIO 52: level=1 fsel=4 alt=0 func=SD0_DAT2
GPIO 53: level=1 fsel=4 alt=0 func=SD0_DAT3
Output of i2cdetect - y 0:

Code: Select all

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- 6b -- -- -- -- 
70: -- -- -- -- -- -- -- --                     
Clearly the firmware and kernel is of the latest version and there is no conflict between the pins for I2C-0. Also my IMU is getting recognised on the I2C-0 bus.
Use something other than your current app to talk to the sensor and confirm you have reliable communications. Unfortunately you have this black box of a C++ library that is masking the true error that it is seeing.
That's the last thing that's left to do now. But then why would the same code work on I2C-1, that too without including any external pull-ups on the I2C-1 SDA and SCL lines? I raised an issue to the author on git. Also, I am planning to probe the SDA and the SCL lines to see if I am getting any data at all on these lines.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 5:17 am

Some more info if it helps:

The last few lines in my /boot/config.txt:

Code: Select all

# Enable audio (loads snd_bcm2835)
dtparam=audio=on
dtparam=i2c_vc=on
#dtparam=i2c1=on

dtoverlay=uart0,txd0_pin=36,rxd0_pin=37,pin_func=6 #alt2
dtoverlay=uart1,txd1_pin=14,rxd1_pin=15
dtoverlay=i2c0-bcm2708,sda0_pin=0,scl0_pin=1
core_freq=250
#force_turbo=0

In /etc/modules:

Code: Select all

i2c-bcm2708
i2c-dev
I am running python3 version 3.5.3. Also I have a lot other sensor in my project like analog temperature sensors, a hall effect sensor, 2 switches, etc. All the sensors are being powered from the 3.3V supply of the CM3L. Could this have anything to do with the IMU not working on I2C-0? Also why is my code running on I2C-1 without any external pullups?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5660
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 5:54 am

I can't explain why it works on i2c-1.
You do not need i2c_bcm2708 in etc/modules and it can cause issues as the kernel normally now uses the upstream i2c_bcm2835 driver.

Another one to check - are both busses running at the same speed? IIRC it gets logged in dmesg during boot.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 5:56 am

I just ran the example code that the author supplied with the LSM9DS1 library. Even that works only on i2c-1 and not on 0. Having made sure that all the hardware and firmware is in the right place, I am certain that it is a library issue only now. I will try with some other library and check.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 5:58 am

6by9 wrote:
Tue Apr 24, 2018 5:54 am
I can't explain why it works on i2c-1.
You do not need i2c_bcm2708 in etc/modules and it can cause issues as the kernel normally now uses the upstream i2c_bcm2835 driver.
Okay will comment out that line from /etc/modules
Another one to check - are both busses running at the same speed? IIRC it gets logged in dmesg during boot.
I dint understand this. Can you explain how exactly I should check the speeds on both the buses?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5660
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 7:13 am

Sohil.Mehta wrote:
Tue Apr 24, 2018 5:58 am
Another one to check - are both busses running at the same speed? IIRC it gets logged in dmesg during boot.
I dint understand this. Can you explain how exactly I should check the speeds on both the buses?
I'd misremembered. It was the old driver that logged in the kernel log the speed during probe.

The new driver you need to look in device tree to see if it is set to something different. Under /proc/device-tree/soc you'll find [email protected] and [email protected] In each you should find a node called clock-frequency which stores the link speed for the I2C bus. If it's missing then the default is 100kHz. Otherwise look at the contents (I suspect it is a binary file, so use xxd instead of cat) for the clock frequency.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 8:53 am

Thanks a lot 6by9. I did as you said:

Code: Select all

$ cd /proc/device-tree/soc/[email protected]
$ xxd clock-frequency
Output:

Code: Select all

00000000: 0001 86a0
And then:

Code: Select all

$ cd /proc/device-tree/soc/[email protected]
$ xxd clock-frequency
Output:

Code: Select all

00000000: 0001 86a0
This means both the buses have the same speed, right?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5660
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 9:21 am

Sohil.Mehta wrote:
Tue Apr 24, 2018 8:53 am
Thanks a lot 6by9. I did as you said:

Code: Select all

$ cd /proc/device-tree/soc/[email protected]
$ xxd clock-frequency
Output:

Code: Select all

00000000: 0001 86a0
And then:

Code: Select all

$ cd /proc/device-tree/soc/[email protected]
$ xxd clock-frequency
Output:

Code: Select all

00000000: 0001 86a0
This means both the buses have the same speed, right?
Yes. Hex 0x186a0 = decimal 100,000, so it is running at 100kHz (same as the default).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Tue Apr 24, 2018 9:52 am

6by9 wrote:
Tue Apr 24, 2018 9:21 am
Yes. Hex 0x186a0 = decimal 100,000, so it is running at 100kHz (same as the default).
Haha. So shall I assume it is a problem with the IMU's library only? All checks on hardware are done.

Sohil.Mehta
Posts: 35
Joined: Thu Feb 01, 2018 6:45 am

Re: I2C0 not working on Compute module 3 Lite

Thu Apr 26, 2018 6:42 am

I ran an ALS code on i2c-0 and it worked!! So the logical conclusion is the IMU library is not supporting i2c-0 on CM3L. Thanks a lot @6by9. Really appreciate all the help and time you gave. Also thanks to @PhilE for his answers on other posts that gave me some good insight.

Return to “Compute Module”

Who is online

Users browsing this forum: No registered users and 7 guests