I2Cmuundur

I2C device rapid tester for debugging and development

  • 3.3 V signal level and power output
  • Six additional IO pins
  • Built-in controllable LED indicator
  • Conditional triggering to read, write and change output pins
  • Analog inputs 0 – 3.3 V (can be used as digital inputs)
  • Selectable pull-up resitors
  • 100 kHz, 400 kHz and 1 MHz clock speed
  • Supports multi-master arbitration (no need to remove original I2C master from the system)

Software

I2Cmuundur software 2020-05-14
Published: May 14, 2020

Applications

  • Test LIS3DSH (3-axis accelerometer) register settings to fine tune the internal state machine. See the status register and output values in real-time.
  • Find correct settings for various I2C sensors, amplifiers etc. No need to write code, compile, reflash the MCU to see the results of different settings.
I2Cmuundur
I2C-USB interface with software
I2Cmuundur

User manual

Main part of the user interface is command table. The table has execution interval about 200 – 210 ms (Limitation of Windows operating system).

All commands are executed from top to bottom direction. If input pin is configured to trigger an action, it may take up to 200 – 210 ms to start the action.

Pinout is marked on the device. Upper and lower pins have the same fuction. It allows to connect two I2C slave devices directly to I2Cmuundur. No need to make splitter cables. Green LED indicates if 3.3 V output power is switched on. Transparent LED is user-controllable.

All signals have series resistor for protection against short-circuit. Therefore it is possible to connect LEDs directly to pins. All signals also have weak pull-down to GND. It has negligible effect on input voltage measurement.

All IO-s function as digital outputs and analog inputs.

Note: Hardware version 1 has IO 2 only in digital input mode.

Pull-up resistors have 4 options:
– No pull-ups (good, if the system already has the resistors mounted)
– 1.5k
– 2.2k
– 4.7k (not recommended for 1 MHz speed)

Use cases

Some real life examples.

LSM303DLHC digital compass

LSM303DLHC digital compass on Mikroe Compass Click board. The idea is to use this sensor for magnetic field detector to make sensitive magnetic switch.

There is a risk, that the sensitivity is not enough to make weak field switch. Fastest and cheapest way to test the concept is to test it before making any dedicated hardware or software.

For magnetic sensors the default (factory) 7-bit slave address is 0011110b = 0x1E. To configure the device, its registers must be written. It is said in the datasheet, that register address increments automatically after every read or write. To configure, firs register address 00 must be sent and followed by tree configuration bytes:

84 – CRA_REG_M. Enables temperature sensor and sets data output update rate 7.5 times per second

80 – CRB_REG_M. Sets gain to the middle of the range. Different values can be tested later

00 – CRM_REG_M.  Enables continuous conversion mode.

Reading data:

X data is in registers 03 and 04. Set the mem addr to 03 and read 2 bytes. As the address counter is incremented automatically in the IC, there is no need to read separately registers 03 and 04.

Note: Output registers do not update before all X, Y and Z   are read.

LPS331AP Pressure/Altitude sensor on Pololu carrier board

This sensor is described as 24-bit absolute pressure sensor. I want to test if it really outputs atmospheric pressure value. In the datasheet it is said that 4096 output units equals to 1 mbar (0.001 Pa) pressure.  The reading should be about 101 325 Pa at sea level. So, the reading should be 4096*0.001*101325 = 415027 ADC units. In hexadecimal numbers 415027d=06 55 33h.

I2Cmuundur

Default sensor 7-bit address in binary is 1011101b. It is 101 in upper half and 1101 in lower half. 101b = 5h and 1101B = Dh. So, the address in hex is 5Dh.

To test if the address is correct, it is best to read a register with known value. According to datasheet, there is a special register at address 0Fh. Its value is always 10111011b. This value in hex is BBh (1011b = Bh, upper and lower parts are the same).

The device responded “OK” and read register 10h value to be 7A. It means address is correct and communication is operational.

Now it is good idea to read the descriptions of all configuration registers and write them all with desired values.

RES_CONF at 10h – I choose value 76h as I don’t have any reason to prefer other numbers. It means the output pressure is average of 128 internal readings and output temperature is average of 64 internal readings. I don’t take maximum values, as it may slow down the response time. Needs to be tested.

CTRL_REG1 at 20h. 1001000b = 90h. Active mode and 1 Hz update rate

CTRL_REG2 – 00h should give normal continuous operation.

CTRL_REG3 – 00h because interrupts are not used.

Actually, after reading the descriptions of other configuration registers, I realized that only the CTRL_REG1 has non-zero value. Registers at 21h to 26h should all be zeroes. Reg at 24h is marked as read-only, but lets see what happens if it is written zero.

Register address can be auto incremented after every write if the address MSB is set to 1.  Therefore, configuration start address is 80h+20h=A0h and configuration numbers bytes to be sent are 90 00 00 00 00 00.

Now it is time to read pressure and temperature. Pressure is read in three separate rows because the register with lowest address has lowest bits of the output. If I read them all at once with address auto increment, the result should be read from right to left. If registers are read one be one, then the output value must be read from top to bottom.

Same is true with temperature output. To verify the result, I calculate the output value at 23C temperature. Temp_OUT=(23-42.5)*480 = -9360 = DB70h