What is I2C, how is it setup, and why would you want to use it? Inter-integrated circuit (I-squared-C) is a way for multiple devices (called slaves) to talk to a primary processor (called a master). Devices on the bus all have an address and are connected to a data line. The master can call these addresses in order to operate the slave and give that particular device information. Along with this data line, there is also a shared clock line which ensures that all devices are in synch with the master and are able to avoid data transmission collisions. In this image, the SCL stands for Serial Clock and SDA stands for Serial Data, and, for this example, the master is a Renesas RX62N MCU and the slave is an EEPROM module.
It can be helpful to compare I2C to SPI and UART. Universal Asynchronous Receiver/Transmitter (UART) works with two wires, like I2C, but its two wires are transmit (Tx) and receive (Rx). UART is usually faster than I2C and easier to implement, but the two devices need to be running at the same clock rate because there is no shared clock line. This also makes adding other devices difficult. There is, however, a form of UART with a clock called USART, to be discussed later. This picture shows the two UART lines, Rx and Tx. It also shows the Baud Rate Generator, which sets up the clock rate on the MCP2120 so that it’s in sync with the other micro controller.
Serial Peripheral Interface (SPI) is synchronous like I2C, is faster than I2C, and is easier to implement. SPI sounds like a better alternative than I2C, but has one major drawback. SPI uses 4 wires, a clock (SCK), a Master out Slave in (MOSI or SI), a Master in Slave out (MISO or SO), and a save state (SS or CS). The real disadvantage is the CS line. SPI, unlike I2C, doesn’t use addresses to reference devices on the bus. Instead, it uses the CS line, which means that every device needs a CS line. This can get very messy very quickly as it can use a lot of pins on your MCU, limiting the number of devices you can have.
In summary, it is important to choose the right bus for the right job. While the RX62N has an I2C bus, it also has ethernet, USB, RS-232, and CAN interfaces that may be better for your specific job. I2C can be difficult to implement and has a lower speed. UART is often a good choice for one-to-one communication, while SPI works for a limited number of peripherals. And, while there are a number of additional bus schemes, many are application-specific and require further discussion.