Home

aliazzz
There is a newer version of this page. You can find it here.

Project Members:


Download file

I2C MCP7941x

Library containing support for battery backed SRAM support provided by realtime clock MCP7941x.

Changelog

v0.0.2.1 stable initial public release

devdescr.xml: vendor id set to 0003, device id set to 0009, see https://forge.codesys.com/drv/io-drivers/database/Home/ for details.

    <DeviceIdentification>
      <Type>500</Type>
      <Id>0003 0009</Id>
      <Version>0.0.2.1</Version>
    </DeviceIdentification>

Installing the I2C MCP7941x

In order to set up a MCP79410 real time clock, start by connecting it to the RPi and a quartz crystal.
The following a rough sketch on how to connect the pins to point one in the right direction - in practice, one might need capacitors to smooth signals or resitors to pull-up the SCL- and SDA-interface, depending for example on the battery and quartz crystal used.

X1: Connect to external 32.768 kHz quartz crystal 
X2: Connect to external 32.768 kHz quartz crystal
VBAT: Connect to external battery
VSS: Connect to GND (e.g. RPi-Pin 9)
VCC: Connect to RPi-Pin 1 (3.3V)
MFP: -
SCL: Connect to RPi-Pin 5 (GPIO3_SCL1)
SDA: Connect to RPi-Pin 3 (GPIO3_SDA1)

install i2c tools

After connecting the hardware, the communication inferace between the MCP79410 and the RPi via I2C can be activated via

sudo raspi-config

Choose Advanced Options -> "A7 I2C" -> "Yes" and exit the tool.
Now update the repository and install i2c-tools

sudo apt-get update
sudo apt-get install i2c-tools

check the adressing/connections

Once you have it installed check that the RTC has been detected using:

sudo i2cdetect -y 0  # (if using v1 Raspberry Pi or)
sudo i2cdetect -y 1  # (if using v2 Raspberry Pi)

This will look something like;

aliazzz@Raspbian:~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- 57 -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 6f
70: -- -- -- -- -- -- -- --

The MCP7941x has two i2c adresses: 0x57 and 0x6f, if the addresses show up they are ready for communication.
0x57 leads to the EEPROM, a status register and a unique ID register whereas 0x6f is the address that leads to the SRAM and RTC itself

The MCP7941x is now ready for use with CODESYS

**NOTE: If "UU" shows in the table, probing was skipped because this address is currently in use by a driver.
This strongly suggests that there is a chip at this address.
You cannot get access to the chip from CODESYS while other software has claimed this resource! **