Intermediate
30 min

Efficiently regulate negative voltages with MCP16331 and PIC32MZ2048EFH100

Voltage flexibility unleashed

MCP16331 INV Click with Flip&Click PIC32MZ

Published Aug 03, 2023

Click board™

MCP16331 INV Click

Dev Board

Flip&Click PIC32MZ

Compiler

NECTO Studio

MCU

PIC32MZ2048EFH100

Experience efficient conversion of input voltages to desired negative levels while benefiting from the dynamic buck-boost capability that ensures stability and accuracy, enabling reliable operation across various applications

A

A

Hardware Overview

How does it work?

MCP16331 INV Click is based on the MCP16331, a step-down (buck) switching regulator from Microchip. However, with the help of a few external components, MCP16331 INV Click can regulate voltage levels lower and higher than the input voltage, working as an inverted boost-buck voltage regulator. The MCP16331 INV click is designed to output a negative voltage with respect to the GND. A negative voltage is often used in the analog electronics domain to power up devices requiring both positive and negative voltages. A good example would be an operational amplifier (opamp) which amplifies an AC signal. The signal goes in both positive and negative directions with respect to the GND. Processing this kind of signal using a single voltage source is difficult and requires workarounds such as capacitors, charge pumps, and virtual GNDs. Using a symmetrical power supply reduces the required components and simplifies the design. Several additional components, such as the ADM8828 voltage inverter IC and the LM318, a dual operational amplifier, must be added to deliver a negative voltage. The ADM8828 voltage inverter IC provides a negative component of the symmetrical power supply used for the LM318 dual opamp. One integrated opamp from the LM318 IC is used to invert the output from the DAC.

The other opamp from the LM318 IC is used to invert the output from the voltage divider, located on the output rail of the MCP16331, so that it can be used by the MCU, which uses a single voltage power source. To set the output voltage of the MCP16331 INV click, the MCP4921 - a low-power 12-Bit dual voltage output DAC is used in the feedback loop. As already mentioned, it is necessary to invert this signal as the MCP4921 is supplied from a single-voltage power supply, and it cannot bring the signal lower than the GND. Since MCP16331 works in the negative voltage domain, the feedback voltage applied to the FB pin of this IC also needs to be negative with respect to the GND. One of the LM318's integrated opamps, configured as a unity gain inverter, is used to invert the DAC output voltage. Since the DAC drives the FB pin of the MCP16331 IC, it is enough to set the DAC to a specific value to control the output voltage of the click board™. Communication with the MCP4921 DAC is done via the SPI interface. SPI bus pins of the MCP4921 are routed to the mikroBUS™ for an easy and secure connection with the host MCU. The AN pin of the mikroBUS™ is routed to a middle point of a voltage divider at the output. This voltage divider is used to scale down the output voltage so the ADC of the host MCU can successfully convert it.

The voltage on the divider also has to be inverted since it is coming out from the negative voltage domain. This is achieved by the second operational amplifier of the LM318 IC, which also works as a unity gain inverter. This value can be used to monitor and correct the output voltage if needed. The EN pin of the MCP16331 switching regulator is routed to the mikroBUS™ RST pin. By pulling this pin to a HIGH logic level, the internal sections of the regulator are enabled. The EN pin is internally pulled to a HIGH logic level, so the device will be enabled, even if this pin is left floating. Therefore, a correct startup sequence must be used to avoid undesirable effects (in the NOTE below). Although it is designed to work as the negative power supply, the MCP16331INV click can also be used to drive a regular load, connecting its positive input terminal to the GND of the click board™ and using the negative output of the MCP16331INV click as the GND. MCP16331 INV Click with two screw terminals to connect the input and the output voltage rails. This click board™ uses only +5V rail from the mikroBUS™. Provided libraries demonstrate the functionality of the MCP16331 INV click and offer an easy and simple way of setting it up.

MCP16331 INV Click hardware overview image

Features overview

Development board

Flip&Click PIC32MZ is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC32MZ microcontroller, the PIC32MZ2048EFH100 from Microchip, four mikroBUS™ sockets for Click board™ connectivity, two USB connectors, LED indicators, buttons, debugger/programmer connectors, and two headers compatible with Arduino-UNO pinout. Thanks to innovative manufacturing technology,

it allows you to build gadgets with unique functionalities and features quickly. Each part of the Flip&Click PIC32MZ development kit contains the components necessary for the most efficient operation of the same board. In addition, there is the possibility of choosing the Flip&Click PIC32MZ programming method, using the chipKIT bootloader (Arduino-style development environment) or our USB HID bootloader using mikroC, mikroBasic, and mikroPascal for PIC32. This kit includes a clean and regulated power supply block through the USB Type-C (USB-C) connector. All communication

methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, user-configurable buttons, and LED indicators. Flip&Click PIC32MZ development kit allows you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

Flip&Click PIC32MZ double 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

Voltage Sense
RB11
AN
Output Enable
RE2
RST
SPI Chip Select
RA0
CS
SPI Clock
RG6
SCK
NC
NC
MISO
SPI Data IN
RB5
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
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

Click board™ Schematic

MCP16331 INV Click Schematic schematic

Step by step

Project assembly

Flip&Click PIC32MZ front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Flip&Click PIC32MZ as your development board.

Flip&Click PIC32MZ front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Flip&Click PIC32MZ MB1 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
Flip&Click PIC32MZ 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

This Click board can be interfaced and monitored in two ways:

  • Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.

Software Support

Library Description

This library contains API for MCP16331 INV Click driver.

Key functions:

  • mcp16331inv_enable_vin - This function enables or disables internal VIN pull up

  • mcp16331inv_set_dac_vout - This function determines DAC output voltage value

  • mcp16331inv_generic_transfer - Generic SPI transfer, for sending and receiving packages

Open Source

Code example

The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.

/*!
 * \file 
 * \brief Mcp16331Inv Click example
 * 
 * # Description
 * This application enables usage of this click as a buck-boost voltage regulator.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes click driver and enables VIN Pull Up.
 * 
 * ## Application Task  
 * Sets DAC output voltage on 3500mV, when gain is set up on 1x VREF,
 * on 4s delay time, and then sets DAC output voltage on 5000mV, when gain is now set up on 2x VREF,
 * on also 4s delay time. VIN Pull Up voltage must be greater than 4V.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "mcp16331inv.h"

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

static mcp16331inv_t mcp16331inv;
static log_t logger;

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

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

    mcp16331inv_cfg_setup( &cfg );
    MCP16331INV_MAP_MIKROBUS( cfg, MIKROBUS_1 );

    Delay_ms( 100 );

    mcp16331inv_init( &mcp16331inv, &cfg );

    Delay_ms( 100 );

    mcp16331inv_enable_vin( &mcp16331inv, MCP16331INV_ENABLE_VIN_PULL_UP );
}

void application_task ( void )
{
    //  Task implementation.

    mcp16331inv_set_dac_vout( &mcp16331inv, MCP16331INV_3500_MV_1X_GAIN, MCP16331INV_GAIN_1X_VREF, MCP16331INV_ACTIVE_MODE );
    Delay_ms( 4000 );
    mcp16331inv_set_dac_vout( &mcp16331inv, MCP16331INV_5000_MV_2X_GAIN, MCP16331INV_GAIN_2X_VREF, MCP16331INV_ACTIVE_MODE );
    Delay_ms( 4000 );
}

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.