How does it work?
I2C MUX 2 click uses the TCA9545A, a 4-channel, bidirectional translating I2C switch. The master SCL/SDA signal pair is directed to four channels of slave devices, SC0/SD0-SC3/SD3. Any individual downstream channel can be selected as well as any combination of the four channels. The TCA9545A also supports interrupt signals in order for the master to detect an interrupt on the INT output terminal that can result from any of the slave devices connected to the INT3-INT0 input terminals. The device offers an active-low RESET input which resets the state machine and allows the TCA9545A to recover should one of the downstream I2C buses get stuck in a low state. The state machine of the device can also be reset by cycling the power supply, VCC, also known as a power-on reset (POR). Both the RESET function and a POR will cause all channels to be deselected.
The connections of the I2C data path are controlled by the same I2C master device that is switched to communicate with multiple I2C slaves. The I2C slave address can be configured by soldering SMD jumpers labeled as ADDR SEL to set the least significant bit (LSB). After the successful acknowledgment of the slave address, a single 8-bit control register is written to or read from to determine the selected channels and state of the interrupts. The TCA9545A may also be used for voltage translation, allowing the use of different bus voltages on each SCn/SDn pair such that 1.8-V, 2.5-V, or 3.3-V parts can communicate with 5-V parts. This is achieved by using external pull-up resistors to pull the bus up to the desired voltage for the master and each slave channel.
One or several SCn/SDn downstream pairs, or channels, are selected by the contents of the control register. After the TCA9545A has been addressed, the control register is written. The four LSBs of the control byte are used to determine which channel or channels are to be selected. When a channel is selected, it becomes active after a stop condition has been placed on the I2C bus. This ensures that all SCn/SDn lines are in a high state when the channel is made active so that no false conditions are generated at the time of connection. A stop condition must occur always right after the acknowledge cycle.
The TCA9545A provides four interrupt inputs (one for each channel) and one open-drain interrupt output. When an interrupt is generated by any device, it is detected by the TCA9545A and the interrupt output is driven low. The channel does not need to be active for the detection of the interrupt. A bit also is set in the control register. Bits 4–7 of the control register correspond to channels 0–3 of the TCA9545A, respectively. Therefore, if an interrupt is generated by any device connected to channel 1, the state of the interrupt inputs is loaded into the control register when a read is accomplished. Likewise, an interrupt on any device connected to channel 0 would cause bit 4 of the control register to be set on the read. The master then can address the TCA9545A and read the contents of the control register to determine which channel contains the device generating the interrupt. The master then can reconfigure the TCA9545A to select this channel and locate the device generating the interrupt and clear it. It should be noted that more than one device can provide an interrupt on a channel, so it is up to the master to ensure that all devices on a channel are interrogated for an interrupt. The interrupt inputs can be used as general-purpose inputs if the interrupt function is not required. If unused, interrupt input(s) must be connected to VCC.
This Click board™ can be supplied and interfaced with both 3.3V and 5V without the need for any external components. The onboard SMD jumper labeled as VCC SEL allows voltage selection for interfacing with both 3.3V and 5V microcontrollers.
Specifications
Type
I2C
Applications
Servers, Routers (telecom switching equipment), Factory automation, Products with I2C slave address conflicts (multiple, identical temp sensors)
On-board modules
I2C MUX 2 Click uses the TCA9545A IC, a quad bidirectional translating switch, from Texas Instruments
Key Features
The 1-of-4 Bidirectional translating switches, Allows voltage-level translation between 1.8-V, 2.5-V, 3.3-V, and 5-V buses
Interface
I2C
Feature
No ClickID
Compatibility
mikroBUS™
Click board size
L (57.15 x 25.4 mm)
Input Voltage
3.3V,5V
Pinout diagram
This table shows how the pinout on I2C MUX click corresponds to the pinout on the mikroBUS™ socket (the latter shown in the two middle columns).
Onboard settings and indicators
Label | Name | Default | Description |
---|---|---|---|
LD1 | PWR | – | Power LED Indicator |
JP1 | VCC SEL | Left | Power Supply Voltage Selection 3V3/5V, left position 3v3, right position 5v |
JP2-3 | ADDR SEL | Right | Slave address LSB selection: left position 1, right position 0 |
Software Support
We provide a library for the I2C MUX 2 Click on our LibStock page, as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Library Description
The library covers all the necessary functions to control I2C MUX 2 click board.
Key functions:
void i2cmux2_hw_reset ( void )
– Hardware reset functionvoid i2cmux2_set_channel ( uint8_t channel, uint8_t ch_slave_address )
– Set channel function.uint8_t i2cmux2_read_interrupt ( void )
– Read interrupt status function.
Examples description
The application is composed of three sections :
- System Initialization – Initializes I2C, set RST pin as output and start to write log.
- Application Initialization – Initialization driver enables – I2C, executes call hardware reset, also write log.
- Application Task – (code snippet) This is an example that demonstrates the use of the I2C MUX 2 Click board. In this example, we read “Who am I” ( or “State” ) register of the connected click boards to the I2C MUX 2 click. Channel 0 : 6DOF IMU 11 click [slave address: 0x0E; reg: 0x00; id val.: 0x2D], Channel 1 : Altintude click [slave address: 0x60; reg: 0x0C; id val.: 0xC4], Channel 2 : 6DOF IMU 9 click [slave address: 0x69; reg: 0x75; id val.: 0xA9], Channel 3 : RTC 10 click [slave address: 0x68; reg: 0x0F; st val.: 0x88]. All data logs write on USB UART changes every 2 sec.
void application_task ( ) { mikrobus_logWrite( " CH | ID | INT " ,_LOG_LINE ); mikrobus_logWrite( "----------------------", _LOG_LINE ); // SET CHANNEL 0: 6DOF IMU 11 click i2cmux2_set_channel( I2CMUX2_CMD_SET_CH_0, 0x0E ); Delay_ms( 100 ); i2cmux2_generic_read( 0x00, &rx_data, 1 ); mikrobus_logWrite( " 0 | 0x", _LOG_TEXT ); display_log( I2CMUX2_CMD_SET_CH_0 ); // SET CHANNEL 1: Altitude click i2cmux2_set_channel( I2CMUX2_CMD_SET_CH_1, 0x60 ); Delay_ms( 100 ); i2cmux2_generic_read( 0x0C, &rx_data, 1 ); mikrobus_logWrite( " 1 | 0x", _LOG_TEXT ); display_log( I2CMUX2_CMD_SET_CH_1 ); // SET CHANNEL 2: 6DOF IMU 9 click i2cmux2_set_channel( I2CMUX2_CMD_SET_CH_2, 0x69 ); Delay_ms( 100 ); i2cmux2_generic_read( 0x75, &rx_data, 1 ); mikrobus_logWrite( " 2 | 0x", _LOG_TEXT ); display_log( I2CMUX2_CMD_SET_CH_2 ); // SET CHANNEL 3: RTC 10 click i2cmux2_set_channel( I2CMUX2_CMD_SET_CH_3, 0x68 ); Delay_ms( 100 ); i2cmux2_generic_read( 0x0F, &rx_data, 1 ); mikrobus_logWrite( " 3 | 0x", _LOG_TEXT ); display_log( I2CMUX2_CMD_SET_CH_3 ); mikrobus_logWrite( "----------------------", _LOG_LINE ); Delay_ms( 2000 ); }
Additional Functions :
void display_log ( uint8_t sel_ch )
– Display data logs.
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
- I2C
- UART
- Conversions
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 click or RS232 click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.
mikroSDK
This Click board™ is supported with mikroSDK – MikroElektronika Software Development Kit. To ensure proper operation of mikroSDK compliant Click board™ demo applications, mikroSDK should be downloaded from the LibStock and installed for the compiler you are using.
For more information about mikroSDK, visit the official page.