Beginner
10 min

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

Expand, Connect, Innovate!

EXPAND 4 Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

EXPAND 4 Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

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

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Shift Register Clear Control
PA7
RST
SPI Chip Select
PD4
CS
SPI Clock
PC6
SCK
NC
NC
MISO
SPI Data IN
PC4
MOSI
NC
NC
3.3V
Ground
GND
GND
Output Enable
PB0
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 Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX Access MB 1 - 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
PIC18F57Q43 Curiosity 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

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

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.