Elevate your I2C communication capabilities and unlock the full potential of your connected devices with our I2C multiplexer solution
A
A
Hardware Overview
How does it work?
I2C MUX 4 Click is based on the TCA9543A, a 2-channel, bidirectional translating I2C switch from Texas Instruments. The master SCL/SDA signal pair is directed to two channels of slave devices SC0/SD0 - SC1/SD1 where either individual channel or both channels can be selected determined by the programmable control register. The TCA9543A supports interrupt signals for the Master to detect an interrupt that can result from any of the slave devices connected to the interrupt pins on the output I2C channel header. It features I2C control using a single 8-bit control register in which bits 1 and 0 control the enabling and disabling of the two switch channels of I2C data flow, it supports a reset function, hot insertion, and has all switch channels deselected during Power-Up. This Click board™ includes a low dropout linear regulator
AP7331 from Diodes Incorporated to provide the 2.45V supply voltage for the TCA9543A. When the TCA9543APWR is turned on for the first time or anytime the device needs to be reset by cycling the power supply, which means that the Power-On reset requirements must be followed to ensure the I2C bus logic is initialized properly. The TCA9543APWR can also be reset to its default conditions by using the Power-On reset feature in the event of a glitch or data corruption. I2C MUX 4 Click communicates with MCU using the standard I2C 2-Wire interface that supports Standard-Mode (100 kHz) and Fast-Mode (400 kHz) operation. The TCA9543A generates a programmable interrupt signal routed on the INT pin of the mikroBUS™ used for the Master to detect an interrupt which can result from any of the slave devices
connected to the output I2C channel pins. It also has two address pins that allow the choice of the least significant bit (LSB) of its I2C slave address which can be done by using the SMD jumper labeled as ADDR SEL, and a Reset function routed on the RST pin of the mikroBUS™ socket used to recover the TCA9543A from a bus-fault condition. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Arduino Mega 2560 is a robust microcontroller platform built around the ATmega 2560 chip. It has extensive capabilities and boasts 54 digital input/output pins, including 15 PWM outputs, 16 analog inputs, and 4 UARTs. With a 16MHz crystal
oscillator ensuring precise timing, it offers seamless connectivity via USB, a convenient power jack, an ICSP header, and a reset button. This all-inclusive board simplifies microcontroller projects; connect it to your computer via USB or power it up
using an AC-to-DC adapter or battery. Notably, the Mega 2560 maintains compatibility with a wide range of shields crafted for the Uno, Duemilanove, or Diecimila boards, ensuring versatility and ease of integration.
Microcontroller Overview
MCU Card / MCU
Architecture
AVR
MCU Memory (KB)
256
Silicon Vendor
Microchip
Pin count
100
RAM (Bytes)
8192
You complete me!
Accessories
Click Shield for Arduino Mega comes equipped with four mikroBUS™ sockets, with two in the form of a Shuttle connector, allowing all the Click board™ devices to be interfaced with the Arduino Mega board with no effort. Featuring an AVR 8-bit microcontroller with advanced RISC architecture, 54 digital I/O pins, and Arduino™ compatibility, the Arduino Mega board offers limitless possibilities for prototyping and creating diverse applications. This board is controlled and powered conveniently through a USB connection to program and debug the Arduino Mega board efficiently out of the box, with an additional USB cable connected to the USB B port on the board. Simplify your project development with the integrated ATmega16U2 programmer and unleash creativity using the extensive I/O options and expansion capabilities. There are eight switches, which you can use as inputs, and eight LEDs, which can be used as outputs of the MEGA2560. In addition, the shield features the MCP1501, a high-precision buffered voltage reference from Microchip. This reference is selected by default over the EXT REF jumper at the bottom of the board. You can choose an external one, as you would usually do with an Arduino Mega board. There is also a GND hook for testing purposes. Four additional LEDs are PWR, LED (standard pin D13), RX, and TX LEDs connected to UART1 (mikroBUS™ 1 socket). This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the Arduino Mega board with Click Shield for Arduino Mega, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via Debug Mode
1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.
2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.
Software Support
Library Description
This library contains API for I2C MUX 4 Click driver.
Key functions:
i2cmux4_get_ch_interrupt
- Get channel interrupt functioni2cmux4_rmt_read_bytes
- Generic read data functioni2cmux4_check_int
- Check interrupt function.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* \file
* \brief I2cMux4 Click example
*
* # Description
* This example demonstrates the use of the I2C MUX 4 Click.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, enables the click board and makes an initial log.
*
* ## Application Task
* In this example, we read the device ID register of the connected click boards.
* Channel 0 : 6DOF IMU 12 click [slave address: 0x68; reg: 0x00; id val.: 0x24],
* Channel 1 : Compass 3 click [slave address: 0x30; reg: 0x2F; id val.: 0x0C].
* All data logs write on USB UART changes every 2 sec.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "i2cmux4.h"
// ------------------------------------------------------------------ VARIABLES
static i2cmux4_t i2cmux4;
static log_t logger;
uint8_t rx_data;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
i2cmux4_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
i2cmux4_cfg_setup( &cfg );
I2CMUX4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
i2cmux4_init( &i2cmux4, &cfg );
i2cmux4_power_on( &i2cmux4, I2CMUX4_ENABLE_POWER_ON );
Delay_ms ( 100 );
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_ALL_DISABLE, 0x00 );
Delay_ms ( 100 );
}
void application_task ( void )
{
// CH 0 - 6DOF IMU 12 click
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_0, 0x68 );
Delay_ms ( 100 );
i2cmux4_rmt_read_bytes( &i2cmux4, 0x00, &rx_data, 1 );
Delay_ms ( 100 );
log_printf( &logger, " 6DOF IMU 12 click \r\n" );
log_printf( &logger, "- - - - - - - - - - - - \r\n" );
log_printf( &logger, " ID = 0x%.2X \r\n", ( uint16_t ) rx_data );
log_printf( &logger, "----------------------- \r\n" );
Delay_ms ( 1000 );
// CH 1 - Compass 3 click
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_1, 0x30 );
Delay_ms ( 100 );
i2cmux4_rmt_read_bytes( &i2cmux4, 0x2F, &rx_data, 1 );
Delay_ms ( 100 );
log_printf( &logger, " Compass 3 click \r\n" );
log_printf( &logger, "- - - - - - - - - - - - \r\n" );
log_printf( &logger, " ID = 0x%.2X \r\n ", ( uint16_t ) rx_data );
log_printf( &logger, "----------------------- \r\n" );
Delay_ms ( 1000 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END
/*!
* \file
* \brief I2cMux4 Click example
*
* # Description
* This example demonstrates the use of the I2C MUX 4 Click.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver, enables the click board and makes an initial log.
*
* ## Application Task
* In this example, we read the device ID register of the connected click boards.
* Channel 0 : 6DOF IMU 12 click [slave address: 0x68; reg: 0x00; id val.: 0x24],
* Channel 1 : Compass 3 click [slave address: 0x30; reg: 0x2F; id val.: 0x0C].
* All data logs write on USB UART changes every 2 sec.
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "i2cmux4.h"
// ------------------------------------------------------------------ VARIABLES
static i2cmux4_t i2cmux4;
static log_t logger;
uint8_t rx_data;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
i2cmux4_cfg_t cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
i2cmux4_cfg_setup( &cfg );
I2CMUX4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
i2cmux4_init( &i2cmux4, &cfg );
i2cmux4_power_on( &i2cmux4, I2CMUX4_ENABLE_POWER_ON );
Delay_ms ( 100 );
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_ALL_DISABLE, 0x00 );
Delay_ms ( 100 );
}
void application_task ( void )
{
// CH 0 - 6DOF IMU 12 click
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_0, 0x68 );
Delay_ms ( 100 );
i2cmux4_rmt_read_bytes( &i2cmux4, 0x00, &rx_data, 1 );
Delay_ms ( 100 );
log_printf( &logger, " 6DOF IMU 12 click \r\n" );
log_printf( &logger, "- - - - - - - - - - - - \r\n" );
log_printf( &logger, " ID = 0x%.2X \r\n", ( uint16_t ) rx_data );
log_printf( &logger, "----------------------- \r\n" );
Delay_ms ( 1000 );
// CH 1 - Compass 3 click
i2cmux4_set_channel( &i2cmux4, I2CMUX4_SEL_CH_1, 0x30 );
Delay_ms ( 100 );
i2cmux4_rmt_read_bytes( &i2cmux4, 0x2F, &rx_data, 1 );
Delay_ms ( 100 );
log_printf( &logger, " Compass 3 click \r\n" );
log_printf( &logger, "- - - - - - - - - - - - \r\n" );
log_printf( &logger, " ID = 0x%.2X \r\n ", ( uint16_t ) rx_data );
log_printf( &logger, "----------------------- \r\n" );
Delay_ms ( 1000 );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END