Skip to content
Baldanos edited this page May 26, 2020 · 50 revisions

HydraFW Bus I2C (Inter-Integrated Circuit)

Bus: I2C (Inter-Integrated Circuit)
Connections: two pins (SDA/SCL) and ground
Output types: open drain/open collector
Pull-up resistors: pull-ups always required (2K - 10K ohms)
Pull-up/down resistors Integrated in MCU: Between 30 to 50K (Typical 40K).
Maximum voltage: 5.5volts (5volt safe)

I2C is a common 2-wire bus for low speed interfaces.

This guide is updated towards development firmware

Protocol configuration syntax description:

  • show Show I2C parameters or show pins Show pins used in this mode

  • pull with parameter up or down or floating to choose internal MCU pull up/down or no pull/external

  • frequency with floating frequency value (support k (for khz), m (for mhz) suffix or no suffix)

    • Frequencies available: 50khz, 100khz, 400khz, 1mhz
  • scan search I2C device(s) from address 0x01 to address 0x77

    • Note: returned scan hexadecimal value corresponds to 7bits I2C address(range 0x01 to 0x77) so it shall be converted to 8bits R or W address before usage.
    • Example: scan returned value 0x3c shall be converted to 8bits I2C address 0x78(Write) or 0x79(Read) see https://github.com/hydrabus/hydrafw/issues/102
  • sniff sniff I2C bus data See below

  • exit to exit I2C mode

Note default value: 
> i2c
GPIO resistor: pull-up
Frequency: 100khz (50khz, 400khz, 1mhz)

Configuration options:

Hardware Informations:

i2c1> show pins
SCL: PB6
SDA: PB7

Protocol configuration example:

Configuration of I2C1 400KHz(using internal MCU pull up):

> i2c
GPIO resistor: pull-up
Frequency: 100khz (50khz, 400khz, 1mhz)

i2c1> frequency 400k show
GPIO resistor: pull-up
Frequency: 400khz (50khz, 100khz, 1mhz)

Protocol interaction syntax description:

Bus interaction commands

trigger configures the trigger mode

start or [ Send I2C Start or Re-Start condition.

stop or ] Send I2C Stop condition.

Protocol interaction example usage I2C1 write/read:

i2c1> [ 0x01 0xFF 0 1 0x80 0x55 0xAA 0xFF 0x11:4 [ 0x00 r:4 ]
I2C START
WRITE: 0x01 ACK 0xFF ACK 0x00 ACK 0x01 ACK 0x80 ACK 0x55 ACK 0xAA ACK 0xFF ACK 0x11 ACK 0x11 ACK 0x11 ACK 0x11 ACK
I2C START
WRITE: 0x00 ACK
READ: 0x00 ACK
READ: 0x00 ACK
READ: 0x00 ACK
READ: 0x00 NACK
I2C STOP

I2C sniffer

I2C sniffer allows to spy an I2C bus. The sniffer is working for buses up to 100kHz.

Syntax is the following :

  • [ : Start condition
  • ] : Stop condition
  • 0x.. byte value send on the bus. Followed by + when an ACK was read or a - if a NACK was read.

Example :

i2c1> sniff 
Interrupt by pressing user button.

[0x80+0x00+0x00+]
[0x80+0x0c+0xaa+]
[0x80+0x0d+0xaa+]
[0x80+0xe2+0xff+0x00+0x00+0x00+0x00+0x00+0x00+0x00+]

Additional informations about I2C

ACK/NACK management is same as BusPirate I2C see chapter ACK/NACK management: http://dangerousprototypes.com/docs/I2C

For more details on I2Cprotocol see: http://en.wikipedia.org/wiki/I%C2%B2C

I2C Pull-up Resistors: It is recommended to use external Pull-Up resistors (for I2C > 100KHz, like 10K for 100Khz and 2.2K for 400KHz/1MHz).

So recommended resistor for I2C is 2.2K.

http://dsscircuits.com/articles/effects-of-varying-i2c-pull-up-resistors

http://www.edn.com/design/analog/4371297/Design-calculations-for-robust-I2C-communications

How to Flash/Use HydraFW

How to Build/Flash/Use HydraFW

Developer Getting-Started with HydraBus and STM32CubeIDE

Hardware

Firmware (hydrafw) performances

Firmware (hydrafw) Application guides

Firmware (hydrafw) guides

How to Help

Clone this wiki locally