How does it work?
Expand 15 Click is based on the TCAL6416, a general-purpose I/O expander from Texas Instruments. The TCAL6416 comes in one P-port configuration and allows easy addition of I/O through a standard I2C serial interface. Its digital core consists of 8-bit data registers, allowing users to configure the I/O port characteristics. The I/Os are configured as inputs at Power-On or after a Reset condition. However, the host controller can configure the I/Os as either inputs or outputs by writing to the Configuration registers. The data for each input or output is kept in the corresponding Input Port or Output Port register, with the possibility to invert the polarity of the Input Port with the Polarity Inversion register. The P-port channels configured as outputs can sink up to 25mA for directly driving LEDs, but the current must be limited externally with additional resistance.
Additionally, the TCAL6416 has Agile I/O functionality specifically targeted to enhance the I/O ports, including programmable output drive strength, programmable pull-up and pull-down resistors, latchable inputs, maskable interrupts, interrupt status register, and programmable open-drain or push-pull outputs. These configuration registers improve the I/O by increasing flexibility and allowing users to optimize their design for power consumption, speed, and EMI.
This Click board™ communicates with MCU using the standard I2C 2-Wire interface to read data and configure settings with a maximum frequency of 1MHz. Also, the TCAL6416 allows choosing the least significant bits (LSB) of its I2C slave address using the SMD jumper labeled ADDR SEL. It also possesses a general reset signal routed on the RST pin of the mikroBUS™ socket to reset the TCAL6416, and an additional interrupt signal, routed on the INT pin of the mikroBUS™ socket whenever an input port changes state.
This Click board™ can only be operated with a 3.3V logic voltage level. Additionally, there is a possibility for the TCAL6416 power supply selection via jumper labeled VCCP SEL to supply the TCAL6416 from 1.08V to 3.6V external power supply (V pin) or with 3V3 mikroBUS™ power rail. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the 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.
Specifications
Type
Port expander
Applications
It provides a simple solution when additional I/Os are needed for switches, sensors, push-buttons, LEDs, fans, and more
On-board modules
TCAL6416 – I/O expander from Texas Instruments
Key Features
Allows bidirectional voltage-level translation and GPIO expansion, low power consumption, fast I2C interface, selectable I2C address, reset and interrupt features, polarity inversion register, various programmable features like output drive strength, pull resistors, and more
Interface
I2C
Feature
ClickID
Compatibility
mikroBUS™
Click board size
M (42.9 x 25.4 mm)
Input Voltage
3.3V,External
Pinout diagram
This table shows how the pinout on Expand 15 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 | VCCP SEL | Left | TCAL6416 Power Supply Selection 3V3/VEXT: Left position 3V3, Right position VEXT |
JP2 | ADDR SEL | Left | I2C Address Selection 0/1: Left position 0, Right position 1 |
Expand 15 Click electrical specifications
Description | Min | Typ | Max | Unit |
---|---|---|---|---|
Supply Voltage | – | 3.3 | – | V |
External Power Supply VEXT | 1.08 | – | 3.6 | V |
Software Support
We provide a library for the Expand 15 Click as well as a demo application (example), developed using Mikroe compilers. The demo can run on all the main Mikroe development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for Expand 15 Click driver.
Key functions
-
expand15_hw_reset
Expand 15 hardware reset function. -
expand15_get_in_pin_state
Expand 15 get input pin state function. -
expand15_set_out_pin_state
Expand 15 set output pin state function.
Example Description
This example demonstrates the use of Expand 15 Click board™ by setting and reading the ports state.
void application_task ( void )
{
uint8_t output_pin_state;
uint8_t input_pin_state;
// Setting port0 output pin ( P00, P02, P04 and P06 ) to high
output_pin_state = EXPAND15_PIN_00_MASK | EXPAND15_PIN_02_MASK | EXPAND15_PIN_04_MASK | EXPAND15_PIN_06_MASK;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH rn" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c rn", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port0 output pin ( P00, P02, P04 and P06 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW rn" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c rn", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - rn" );
Delay_ms( 2000 );
// Setting port1 output pin ( P10, P12, P14 and P01 ) to high
output_pin_state = EXPAND15_PIN_10_MASK | EXPAND15_PIN_12_MASK | EXPAND15_PIN_14_MASK | EXPAND15_PIN_16_MASK;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH rn" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c rn", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port1 output pin ( P10, P12, P14 and P16 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_out_pin_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_in_pin_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW rn" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c rn", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - rn" );
Delay_ms( 2000 );
}
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.Expand15
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. UART terminal is available in all Mikroe compilers.
mikroSDK
This Click board™ is supported with mikroSDK – Mikroe Software Development Kit, that needs to be downloaded from the LibStock and installed for the compiler you are using to ensure proper operation of mikroSDK compliant Click board™ demo applications.
For more information about mikroSDK, visit the official page.