Intermediate
30 min

Efficiently regulate negative voltages with MCP16331 and STM32L073RZ

Voltage flexibility unleashed

MCP16331 INV Click with Nucleo-64 with STM32L073RZ MCU

Published Feb 26, 2024

Click board™

MCP16331 INV Click

Dev. board

Nucleo-64 with STM32L073RZ MCU

Compiler

NECTO Studio

MCU

STM32L073RZ

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

Nucleo-64 with STM32L073RZ MCU offers a cost-effective and adaptable platform for developers to explore new ideas and prototype their designs. This board harnesses the versatility of the STM32 microcontroller, enabling users to select the optimal balance of performance and power consumption for their projects. It accommodates the STM32 microcontroller in the LQFP64 package and includes essential components such as a user LED, which doubles as an ARDUINO® signal, alongside user and reset push-buttons, and a 32.768kHz crystal oscillator for precise timing operations. Designed with expansion and flexibility in mind, the Nucleo-64 board features an ARDUINO® Uno V3 expansion connector and ST morpho extension pin

headers, granting complete access to the STM32's I/Os for comprehensive project integration. Power supply options are adaptable, supporting ST-LINK USB VBUS or external power sources, ensuring adaptability in various development environments. The board also has an on-board ST-LINK debugger/programmer with USB re-enumeration capability, simplifying the programming and debugging process. Moreover, the board is designed to simplify advanced development with its external SMPS for efficient Vcore logic supply, support for USB Device full speed or USB SNK/UFP full speed, and built-in cryptographic features, enhancing both the power efficiency and security of projects. Additional connectivity is

provided through dedicated connectors for external SMPS experimentation, a USB connector for the ST-LINK, and a MIPI® debug connector, expanding the possibilities for hardware interfacing and experimentation. Developers will find extensive support through comprehensive free software libraries and examples, courtesy of the STM32Cube MCU Package. This, combined with compatibility with a wide array of Integrated Development Environments (IDEs), including IAR Embedded Workbench®, MDK-ARM, and STM32CubeIDE, ensures a smooth and efficient development experience, allowing users to fully leverage the capabilities of the Nucleo-64 board in their projects.

Nucleo 64 with STM32L073RZ MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

192

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

20480

You complete me!

Accessories

Click Shield for Nucleo-64 comes equipped with two proprietary mikroBUS™ sockets, allowing all the Click board™ devices to be interfaced with the STM32 Nucleo-64 board with no effort. This way, Mikroe allows its users to add any functionality from our ever-growing range of Click boards™, such as WiFi, GSM, GPS, Bluetooth, ZigBee, environmental sensors, LEDs, speech recognition, motor control, movement sensors, and many more. More than 1537 Click boards™, which can be stacked and integrated, are at your disposal. The STM32 Nucleo-64 boards are based on the microcontrollers in 64-pin packages, a 32-bit MCU with an ARM Cortex M4 processor operating at 84MHz, 512Kb Flash, and 96KB SRAM, divided into two regions where the top section represents the ST-Link/V2 debugger and programmer while the bottom section of the board is an actual development board. These boards are controlled and powered conveniently through a USB connection to program and efficiently debug the Nucleo-64 board out of the box, with an additional USB cable connected to the USB mini port on the board. Most of the STM32 microcontroller pins are brought to the IO pins on the left and right edge of the board, which are then connected to two existing mikroBUS™ sockets. This Click Shield also has several switches that perform functions such as selecting the logic levels of analog signals on mikroBUS™ sockets and selecting logic voltage levels of the mikroBUS™ sockets themselves. Besides, the user is offered the possibility of using any Click board™ with the help of existing bidirectional level-shifting voltage translators, regardless of whether the Click board™ operates at a 3.3V or 5V logic voltage level. Once you connect the STM32 Nucleo-64 board with our Click Shield for Nucleo-64, you can access hundreds of Click boards™, working with 3.3V or 5V logic voltage levels.

Click Shield for Nucleo-64 accessories 1 image

Used MCU Pins

mikroBUS™ mapper

Voltage Sense
PC0
AN
Output Enable
PC12
RST
SPI Chip Select
PB12
CS
SPI Clock
PB3
SCK
NC
NC
MISO
SPI Data IN
PB5
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

Click Shield for Nucleo-64 accessories 1 image hardware assembly

Start by selecting your development board and Click board™. Begin with the Nucleo-64 with STM32L073RZ MCU as your development board.

Click Shield for Nucleo-64 accessories 1 image hardware assembly
Nucleo 64 with STM32F401RE MCU front image hardware assembly
LTE IoT 5 Click front image hardware assembly
Prog-cut hardware assembly
LTE IoT 5 Click complete accessories setup image hardware assembly
Nucleo-64 with STM32XXX MCU Access MB 1 Mini B Conn - 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
Clicker 4 for STM32F4 HA 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

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.