Getting Started with I2C

From Embedded Workshop
Jump to navigation Jump to search

Agenda

What we are going to talk about:

  • I2C
  • DS3231 Real Time Clock (RTC)
  • AT24C32 32Kbit EEPROM (4096 bytes)
  • TM1637 7-segment LED driver (decimal points or colon)
  • Logic8 / Logic16 logic analyzer
Begin by watching the following "Understanding I2C" video:
  https://www.youtube.com/watch?v=CAvawEcxoPU
1) What is I2C - The bus hardware
2) START and STOP conditions (These are NOT bits)
3) I2C Address and the R /W bit - (7 or 8 bit I2C address ?)
4) Acknowledge bit (receiver of data provides acknowledge)
5) What isn't I2C?  Examine the TM1637
5) Examine the DS3231, write and read it's registers
6) Examine the AT24C32, write and read data

DS3231 Module

DS3231

The time (and temperature), are accessed via 19 byte-wide registers, see Address Map on page 11.
https://www.analog.com/media/en/technical-documentation/data-sheets/ds3231.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/ds3231m.pdf (The 'M' variant)

Reading DS3231 control register (0x0E)

AT24C32

This 32Kbit EEPROM (4096 x 8), will hold 4096 bytes of data.
https://ww1.microchip.com/downloads/en/DeviceDoc/doc0336.pdf

Writing 16 bytes using page write

Following a write, polling the device, waiting for ACK to signal device is ready'

TM1637

Multiple 7-segment LED display driver / keypad scanner
https://www.aliexpress.us/item/3256801873805909.html (decimal points)
https://www.aliexpress.us/item/3256801704898010.html (decimal points)
https://www.aliexpress.us/item/3256801873036951.html (colon)

Waveforms captured during a clock update

The Software

Arduino Example:
https://github.com/JimMerkle/Arduino_Uno_Command_Line_I2C_DS3231_TM1637
NUCLEO-F103RB Example:
https://github.com/JimMerkle/NUCLEO-F103RB_TM1637_DS3231_Clock

References

https://www.analog.com/en/resources/technical-articles/i2c-primer-what-is-i2c-part-1.html
https://www.ti.com/lit/an/sbaa565/sbaa565.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/ds3231.pdf
https://www.arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-schematic.pdf