How does it work?
I2C MUX click is packed with the TCA9546A, a quad bidirectional translating switch controlled via the I2C bus. The SCL/SDA upstream pair fans out to four downstream pairs, or channels. Any individual SCn/SDn channel or combination of channels can be selected, determined by the contents of the programmable control register. An active-low reset (RESET) input allows the TCA9546A to recover from a situation in which one of the downstream I2C buses is stuck in a low state. Pulling RESET low resets the I2C state machine and causes all the channels to be deselected, as does the internal power-on reset function. The pass gates of the switches are constructed such that the VCC pin can be used to limit the maximum high voltage, which will be passed by the TCA9546A. This allows the use of different bus voltages on each pair, so that 1.8-V, 2.5-V, or 3.3-V parts can communicate with 5-V parts without any additional protection. The slave devices can be connected to four headers located on the top of the I2C MUX click.
The TCA9546A supports Standard-Mode (100 kHz) and Fast-Mode (400 kHz) operation. This way, the bus can be used to manage a single 8-bit control register in which the four least significant bits control the enabling and disabling of the 4 switch channels of I2C data flow. The I2C bus is for two-way two-line communication between different ICs or modules. The two lines are a serial data line (SDA) and a serial clock line (SCL). Both lines must be connected to a positive supply via a pullup resistor when connected to the output stages of a device. Data transfer can be initiated only when the bus is not busy. One data bit is transferred during each clock pulse. The data on the SDA line must remain stable during the high period of the clock pulse, as changes in the data line at this time are interpreted as control signals.
Applications of the TCA9546A contains an I2C (or SMBus) master device and up to four I2C slave devices. The downstream channels are ideally used to resolve the I2C slave address conflicts. For example, if four identical digital temperature sensors are needed in the application, one sensor can be connected at each channel: 0, 1, 2, and 3. When the temperature at a specific location needs to be read, the appropriate channel can be enabled and all other channels switched off, the data can be retrieved, and the I2C master can move on and read the next channel.
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 Click uses the TCA9546A IC, a quad bidirectional translating switch, from Texas Instruments |
Key Features |
Voltage translation between 1.8V, 2.5V, 3.3V, and 5V buses, hot insertion, 0 - 400 kHz clock frequency range |
Interface |
I2C |
Click board size |
M (42.9 x 25.4 mm) |
Input Voltage |
3.3V or 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).
Notes |
Pin |
|
Pin |
Notes |
---|
|
NC |
1 |
AN |
PWM |
16 |
NC |
|
Reset |
RST |
2 |
RST |
INT |
15 |
NC |
|
|
NC |
3 |
CS |
RX |
14 |
NC |
|
|
NC |
4 |
SCK |
TX |
13 |
NC |
|
|
NC |
5 |
MISO |
SCL |
12 |
SCL |
I2C Clock |
|
NC |
6 |
MOSI |
SDA |
11 |
SDA |
I2C Data |
Power Supply |
3.3V |
7 |
3.3V |
5V |
10 |
5V |
Power Supply |
Ground |
GND |
8 |
GND |
GND |
9 |
GND |
Ground |
Onboard settings and indicators
Label |
Name |
Default |
Description |
---|
LD1 |
PWR |
- |
Power LED Indicator |
JP1 |
VCC SEL |
Right |
Power Supply Voltage Selection: left position 3V3, right position 5V |
JP2-4 |
ADD SEL |
Right |
Slave Address Selection: left position 1, right position 0 |
Software Support
We provide a library for the I2C MUX 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 click board.
Key functions:
void i2cmux_hw_reset ( void )
- Hardware reset function.
void i2cmux_set_channel ( uint8_t channel, uint8_t ch_slave_address )
- Set channel function.
void i2cmux_generic_read ( uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes )
- Generic read data 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 Click board. In this example, we read "Who am I" register of the connected click boards to the UART MUX click. Channel 0 : 6DOF IMU 9 click [ slave address: 0x69; reg: 0x75; id val.: 0xA9 ], Channel 1 : RTC 10 click [ slave address: 0x68; reg: 0x0F; id val.: 0x88 ], Channel 2 : Altintude click [ slave address: 0x60; reg: 0x0C; id val.: 0xC4 ], Channel 3 : Temp & Hum click [ slave address: 0x5F; reg: 0x0F; id val.: 0xBC ]. All data logs write on USB UART changes every 2 sec.
void application_task ( )
{
// SET CHANNEL 0: 6DOF IMU 9 click
i2cmux_set_channel( I2CMUX_CMD_SET_CH_0, 0x69 );
Delay_ms( 100 );
i2cmux_generic_read( 0x75, &rx_data, 1 );
mikrobus_logWrite( " CH-0 : ID = 0x", _LOG_TEXT );
display_log( );
// SET CHANNEL 1: RTC 10 click
i2cmux_set_channel( I2CMUX_CMD_SET_CH_1, 0x68 );
Delay_ms( 100 );
i2cmux_generic_read( 0x0F, &rx_data, 1 );
mikrobus_logWrite( " CH-1 : ST = 0x", _LOG_TEXT );
display_log( );
// SET CHANNEL 2: Altitude click
i2cmux_set_channel( I2CMUX_CMD_SET_CH_2, 0x60 );
Delay_ms( 100 );
i2cmux_generic_read( 0x0C, &rx_data, 1 );
mikrobus_logWrite( " CH-2 : ID = 0x", _LOG_TEXT );
display_log( );
// SET CHANNEL 3: Temp & Hum click
i2cmux_set_channel( I2CMUX_CMD_SET_CH_3, 0x5F );
Delay_ms( 100 );
i2cmux_generic_read( 0x0F, &rx_data, 1 );
mikrobus_logWrite( " CH-3 : ID = 0x", _LOG_TEXT );
display_log( );
mikrobus_logWrite( "------------------", _LOG_LINE );
Delay_ms( 2000 );
}
void display_log ( void )
- Display log function.
The full application code, and ready to use projects can be found on our LibStock page.
Other mikroE Libraries used in the example:
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.
Resources
Downloads