Beginner
10 min

Experience a seamless expansion of I/O pins with TPIC6A595 and PIC32MZ2048EFM100

Expand, Connect, Innovate!

EXPAND 4 Click with Curiosity PIC32 MZ EF

Published Sep 21, 2023

Click board™

EXPAND 4 Click

Dev Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Unlock new levels of connectivity and control as our port expander technology provides you with the tools to expand your I/O capabilities, effortlessly manage data flow, and improve the efficiency of your electronic systems

A

A

Hardware Overview

How does it work?

Expand 4 Click is based on the TPIC6A595, a monolithic, high-voltage, high-current power logic 8-bit shift register from Texas Instruments. The TPIC6A595 contains a built-in voltage clamp on the outputs for inductive transient protection. Each output is a low-side, open-drain DMOS transistor with output ratings of 50V and a 350mA continuous sink current capability, featuring an independent chopping current-limiting circuit to prevent damage in the case of a short circuit. This Click board™ is designed for use in systems that require relatively high load power, such as relays, solenoids, and other medium-current or high-voltage loads. This TPIC6A595 contains an 8-bit serial-in, parallel-out shift register that feeds an 8-bit, D-type storage register. Data transfers through the shift and storage register on the rising edge

of the shift register clock (SPI clock pin on the mikroBUS™ socket) and the register clock (CS clock pin on the mikroBUS™ socket), respectively. The storage register transfers data to the output buffer when the shift register clear pin is set to a high logic state. This function can be done via the existing CLR jumper by placing it in the appropriate VCC or CLR position. In this way, it is possible to permanently bind this function so that the storage register always transfers data to the output buffer by setting the jumper to the VCC position or controlled digitally by setting the jumper to the CLR position. This way, controlling the shift-register-clear via the RST pin of the mikroBUS™ socket marked as CLR is possible. The input shift register is cleared when CLR is in a low logic state. In the same way, it is possible to

manage the outputs of the port expander, eight pins above the mikroBUS™ socket (D0-D7), using EN jumper, more precisely define the output management mode, constantly ON or digital control over them through PWM pin of the mikroBUS™ socket marked as EN. When the EN pin is held in a high logic state, all data in the output buffers is kept low, and all drain outputs are OFF. When EN is LOW, data from the storage register is transparent to the output buffers. This Click board™ can be operated only with a 5V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

EXPAND 4 Click hardware overview image

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Shift Register Clear Control
RA9
RST
SPI Chip Select
RPD4
CS
SPI Clock
RPD1
SCK
NC
NC
MISO
SPI Data IN
RPD3
MOSI
NC
NC
3.3V
Ground
GND
GND
Output Enable
RPE8
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

EXPAND 4 Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Curiosity PIC32 MZ EF MB 1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware 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.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for EXPAND 4 Click driver.

Key functions:

  • expand4_write_data - Function write 8-bit data function to TPIC6A595 shift register

  • expand4_enable_output - Function turn on output buffers - set PWM pin low

  • expand4_reset - Function clear input TPIC6A595 shift register.

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 Expand4 Click example
 * 
 * # Description
 * Example demonstrates use of Expand 4 Click board.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initialization driver enable's - Clear TPIC6A595 register and start write log.
 * 
 * ## Application Task  
 * This is a example which demonstrates the use of Expand 4 Click board.
 * In this example, the LED pin mask is transferred via SPI bus,
 * LEDs connected to D0-D7 pins are lit accordingly by turning ON LEDs from D0 to D7 for 3 sec.
 * Results are being sent to the Usart Terminal where you can track their changes.
 * All data logs on usb uart for aproximetly every 3 sec. when the change pin who is connected.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "expand4.h"

// ------------------------------------------------------------------ VARIABLES

static expand4_t expand4;
static log_t logger;

// ------------------------------------------------------ APPLICATION FUNCTIONS

void application_init ( void )
{
    log_cfg_t log_cfg;
    expand4_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.

    expand4_cfg_setup( &cfg );
    EXPAND4_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    expand4_init( &expand4, &cfg );
    expand4_reset( &expand4 );
}

void application_task ( void )
{
    uint8_t pin_position;

    for ( pin_position = 0; pin_position < 8; pin_position++ )
    {
        expand4_disable_output( &expand4 );
        Delay_ms( 100 );

        expand4_turn_on_by_position( &expand4, pin_position );
        Delay_ms( 100 );

        log_printf( &logger, " D%d", pin_position );

        expand4_enable_output( &expand4 );
        Delay_ms( 3000 );
    }

    log_printf( &logger, "\n----------------------------------\n");
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}

// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.