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
Clicker 4 for STM32F4 is a compact development board designed as a complete solution that you can use to quickly build your own gadgets with unique functionalities. Featuring an STM32F407VGT6 MCU, four mikroBUS™ sockets for Click boards™ connectivity, power management, and more, it represents a perfect solution for the rapid development of many different types of applications. At its core is an STM32F407VGT6 MCU, a powerful microcontroller by STMicroelectronics based on the high-performance
Arm® Cortex®-M4 32-bit processor core operating at up to 168 MHz frequency. It provides sufficient processing power for the most demanding tasks, allowing Clicker 4 to adapt to any specific application requirements. Besides two 1x20 pin headers, four improved mikroBUS™ sockets represent the most distinctive connectivity feature, allowing access to a huge base of Click boards™, growing on a daily basis. Each section of Clicker 4 is clearly marked, offering an intuitive and clean interface. This makes working with the
development board much simpler and, thus, faster. The usability of Clicker 4 doesn’t end with its ability to accelerate the prototyping and application development stages: it is designed as a complete solution that can be implemented directly into any project, with no additional hardware modifications required. Four mounting holes [4.2mm/0.165”] at all four corners allow simple installation by using mounting screws.
Microcontroller Overview
MCU Card / MCU
Architecture
ARM Cortex-M4
MCU Memory (KB)
10
Silicon Vendor
STMicroelectronics
Pin count
100
RAM (Bytes)
100
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