AllenLey
Posts: 3
Joined: Tue Jul 31, 2018 2:07 pm

Using RTC on CM GPIO 0 and 1

Tue Jul 31, 2018 2:38 pm

I'm using a custom CM3 carrier board and am using GPIO 0 and 1 for the I2C bus. I have a DS3231 and ADS1115 on the bus. After adding "dtoverlay=i2c-gpio,i2c_gpio_sda=0,i2c_gpio_scl=1" I can see both ICs in bus 3 using i2cdetect -y 3 I get:
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

I've been using the Adafruit library for the DAS1115 and with a minor adjustment that's working fine. Now I'd like to use the DS3231 as the HWclock but haven't been able to. I tried the standard way by adding "dtoverlay=i2c-rtc,ds3231" but that didn't work, after rebooting the output for i2c detect is the same (still shows 68 instead of UU).

I tried then using this viewtopic.php?t=187092 post but dtoverlay=i2c-gpio-rtc didn't work once I changed it for my case
dtoverlay=i2c-gpio-rtc,ds3231,i2c_gpio_sda=0,i2c_gpio_scl=1.

How can I set up the DS321?

Thanks in advance

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1822
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Using RTC on CM GPIO 0 and 1

Tue Jul 31, 2018 5:39 pm

It is unclear from your post how many overlays you have now accumulated - please post the contents of config.txt (or at least the settings you have changed) - I suspect there may be a clash for pin usage.

It is also unclear if you understand that i2c-gpio is a bit-bashed/software I2C bus - have you chosen that for a reason? I2C0 will work on GPIOs 0&1 with "dtparam=i2c0=on" to config.txt.

The standard i2c-rtc overlay is set up to use I2C1, but it is straightforward to modify it to use I2C0 instead.

AllenLey
Posts: 3
Joined: Tue Jul 31, 2018 2:07 pm

Re: Using RTC on CM GPIO 0 and 1

Tue Jul 31, 2018 5:58 pm

Currently I only have one overlay - "dtoverlay=i2c-gpio,i2c_gpio_sda=0,i2c_gpio_scl=1". I removed the "i2c-gpio-rtc" after it didn't work, and I only had one at a time.

I understand that this is a software bus and is different from a hardware I2C - this was done mainly for routing constraints when laying out the board that are unrelated to the question, the board is here and I am not able to respin it for now.

How would I modify the rtc overlay to work with my current set up?

thanks!

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1822
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Using RTC on CM GPIO 0 and 1

Tue Jul 31, 2018 6:22 pm

1. Download the source to the standard overlay from here.

2. Change all occurrences of &i2c_arm to &i2c0, and save it as i2c0-rtc-overlay.dts.

3. Compile and install the new overlay with:

Code: Select all

$ dtc [email protected] -I dts -O dtb -o i2c0-rtc.dtbo i2c0-rtc-overlay.dts
$ sudo cp i2c0-rtc.dtbo /boot/overlays
4. Use with:

Code: Select all

dtoverlay=i2c0-rtc,ds3231

AllenLey
Posts: 3
Joined: Tue Jul 31, 2018 2:07 pm

Re: Using RTC on CM GPIO 0 and 1

Tue Jul 31, 2018 6:54 pm

Thank you, PhilE. This has solved my issue.

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 1 guest