Beginner
10 min

Provide essential functions for charging and managing battery power in electronic devices with nPM1300 and STM32F030R8

Advanced Power Management Integrated Circuit (PMIC) for rechargeable applications

PMIC Click with Nucleo-64 with STM32F030R8 MCU

Published Aug 21, 2024

Click board™

PMIC Click

Dev. board

Nucleo-64 with STM32F030R8 MCU

Compiler

NECTO Studio

MCU

STM32F030R8

Optimize battery life and performance in IoT applications and other portable electronics ensuring longer operation times

A

A

Hardware Overview

How does it work?

PMIC Click is based on the nPM1300, an advanced Power Management Integrated Circuit (PMIC) from Nordic Semiconductor designed for rechargeable applications. The nPM1300 integrates a variety of power and system management functionalities, offering a compact and efficient solution for managing power in devices. It supports battery charging for lithium-ion (Li-ion), lithium-polymer (Li-poly), and lithium iron phosphate (LiFePO4) batteries, using a flexible power regulation system. Housed in a space-saving QFN32 package, the nPM1300 is made for high efficiency and is fully configurable via an I2C interface, making it ideal for wearables, peripherals, asset tracking, interactive entertainment, IoT applications, and much more. The nPM1300 features an integrated 800mA linear battery charger that ensures safe and efficient charging by adhering to the JEITA standards, which adjusts the charging process based on temperature to protect the battery and extend its lifespan. A battery can be connected to a connector in the upper right corner that supports the integration of an NTC thermistor for precise battery temperature monitoring. If the used battery pack already includes an NTC, the NTC terminal on the BATTERY connector can be left unconnected. For scenarios where a battery without an NTC thermistor is used, the board provides options to bypass this requirement by using onboard resistors. An integrated 10K resistor is available by default, or you can customize the value via an empty resistor footprint (R7 0603) to match specific needs. This feature can be selected via an onboard NTC Bypass jumper. Besides the battery charger, the nPM1300 also integrates two 200mA buck regulators and two 100mA load switches or 50mA Low Dropout Regulators (LDOs). These load switches offer flexibility in managing power distribution across your device. Control of these load switches is achieved through I2C registers or GPIO pins, providing flexibility to tailor the power

configuration to your application's requirements. A notable feature is the ability to select the input source for a second load switch via the LSIN2 jumper, allowing you to choose between the output voltage of one of the buck regulators (VOUT1 or VOUT2). The regulated outputs, VOUT1 and VOUT2, are currently configured to output 1.8V, and VOUT2 is set to 3.3V. These configurations are achieved through specific resistor settings - R8 for VOUT1 and R9 for VOUT2, where VOUT1 can be adjusted within a range of 0V to 2.7V, while VOUT2 from 0V to 3.3V, depending on the selected resistor values. Unregulated output VBUSOUT is directly tied to the VBUS input, offering an unregulated power source that can be used for additional system needs, while VSYS serves as another unregulated output derived from the system's overall power supply. The primary power supply for the nPM1300 PMIC is provided by the VBUS connection, which is a dedicated USB Type-C input. Alongside VBUS, the complementary power supply is VBAT, which also acts as the output for the battery charger, ensuring that the connected battery is charged while maintaining a stable power supply to the system. In addition, the nPM1300 also enhances system reliability with a watchdog that resets the system if it becomes unresponsive, failed-boot recovery for system integrity, and an intelligent power-loss warning to prevent data loss or failure. PMIC Click uses a standard 2-wire I2C interface for communication with the host MCU, supporting a clock frequency of up to 400kHz in Standard mode. Besides interface pins, the board also features an interrupt (INT) pin providing real-time alerts to the host system for immediate action. To manage the power states, PMIC Click includes a SHPHLD button to exit Ship and Hibernation mode - two of the lowest quiescent current states available. These modes disconnect the battery from the system, reducing the quiescent current to extend the battery life. Hibernate mode, in

particular, can be used during normal operation, as the device can automatically wake up after a preconfigured timeout, maximizing battery efficiency. The SHPHLD button also allows users to reset or power cycle the nPM1300. For additional control, the board is equipped with a GPIO0 button, which directly manages the nPM1300's GPIO0 pin. Three LED indicators provide visual feedback: a red ERR LED that signals errors during operation, a green CHG LED that indicates the charging status, and a yellow HOST LED that shows host activity. These LEDs offer clear and immediate visual cues, making monitoring the board's status and troubleshooting any issues easier. Two headers, J1 and J2, provide easy access to power and control functions. The J1 header grants access to the PMIC's voltage outputs, VOUT1 and VOUT2, as well as the USB VBUS voltage through the VBUS pin and VBUSOUT from the nPM1300, allowing you to power external devices directly from the main IC. The J2 header serves multiple purposes, primarily enabling connections to PMIC GPIO pins located in the right column. These GPIOs, configured as inputs with weak pull-downs by default, can be used for custom workflows, standard GPIO functions, or as control pins for the board's buck regulators and load switches. Additionally, the J2 header supports connections for external LEDs and includes the previously mentioned VSYS pin, a system voltage output. This Click board™ can operate with either 3.3V or 3.3V provided from VOUT2 regulated PMIC output selected via the VDDIO SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this 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.

PMIC Click hardware overview image

Features overview

Development board

Nucleo-64 with STM32F030R8 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 STM32F030R8 MCU double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

ARM Cortex-M0

MCU Memory (KB)

64

Silicon Vendor

STMicroelectronics

Pin count

64

RAM (Bytes)

8192

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

Li-Polymer Battery is the ideal solution for devices that demand a dependable and long-lasting power supply while emphasizing mobility. Its compatibility with mikromedia boards ensures easy integration without additional modifications. With a voltage output of 3.7V, the battery meets the standard requirements of many electronic devices. Additionally, boasting a capacity of 2000mAh, it can store a substantial amount of energy, providing sustained power for extended periods. This feature minimizes the need for frequent recharging or replacement. Overall, the Li-Polymer Battery is a reliable and autonomous power source, ideally suited for devices requiring a stable and enduring energy solution.

PMIC Click accessories 2 image

This is a USB 3.1 cable with USB Type C male connectors on both sides. Cable comes with USB Type C Female to USB Type A Male adapter, making it compabitle with USB 2.0 and USB 3.0 host slots as well. Cable is 1.5 meters long and compatible with any USB type C development tools.

PMIC Click accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
NC
NC
RST
ID COMM
PB12
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
Interrupt
PC14
INT
NC
NC
TX
NC
NC
RX
I2C Clock
PB8
SCL
I2C Data
PB9
SDA
NC
NC
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

PMIC 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 STM32F030R8 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 PMIC Click driver.

Key functions:

  • pmic_get_vbat - This function reads the VBAT measurement results in millivolts.

  • pmic_get_vbus - This function reads the VBUS measurement results in millivolts.

  • pmic_get_vsys - This function reads the VSYS measurement results in millivolts.

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 main.c
 * @brief PMIC Click example
 *
 * # Description
 * This example demonstrates the use of PMIC click board by enabling battery charging and
 * displaying the charging status.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and performs the click default configuration which enables charging.
 *
 * ## Application Task
 * Reads and displays the VBAT, VBUS, and VSYS voltage and the battery charging status on the USB UART
 * approximately once per second.
 *
 * @note
 * A charged battery or a USB at VBUS must be connected to communicate with the click board.
 *
 * @author Stefan Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "pmic.h"

static pmic_t pmic;
static log_t logger;

/**
 * @brief PMIC display charger status function.
 * @details This function reads and parses the battery charger status register.
 * @param[in] ctx : Click context object.
 * See #pmic_t object definition for detailed explanation.
 * @return None.
 * @note None.
 */
void pmic_display_charger_status ( pmic_t *ctx );

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    pmic_cfg_t pmic_cfg;  /**< Click config object. */

    /** 
     * 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.
    pmic_cfg_setup( &pmic_cfg );
    PMIC_MAP_MIKROBUS( pmic_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == pmic_init( &pmic, &pmic_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( PMIC_ERROR == pmic_default_cfg ( &pmic ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

void application_task ( void ) 
{
    uint16_t vbat = 0, vbus = 0, vsys = 0;
    if ( PMIC_OK == pmic_get_vbat ( &pmic, &vbat ) )
    {
        log_printf( &logger, " VBAT : %u mV\r\n", vbat );
    }
    if ( PMIC_OK == pmic_get_vbus ( &pmic, &vbus ) )
    {
        log_printf( &logger, " VBUS : %u mV\r\n", vbus );
    }
    if ( PMIC_OK == pmic_get_vsys ( &pmic, &vsys ) )
    {
        log_printf( &logger, " VSYS : %u mV\r\n\n", vsys );
    }
    pmic_display_charger_status ( &pmic );
    Delay_ms ( 1000 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

void pmic_display_charger_status ( pmic_t *ctx )
{
    uint8_t charge_status = 0;
    if ( PMIC_OK == pmic_reg_read_byte ( &pmic, PMIC_REG_BCHARGER_BCHGCHARGESTATUS, &charge_status ) )
    {
        log_printf( &logger, " --- Battery Charge status ---\r\n" );
        if ( charge_status & PMIC_CHARGE_STATUS_BATTERYDETECTED )
        {
            log_printf( &logger, " Battery is connected\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_COMPLETED )
        {
            log_printf( &logger, " Charging completed (Battery Full)\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_TRICKLECHARGE )
        {
            log_printf( &logger, " Trickle charge\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_CONSTANTCURRENT )
        {
            log_printf( &logger, " Constant Current charging\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_CONSTANTVOLTAGE )
        {
            log_printf( &logger, " Constant Voltage charging\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_RECHARGE )
        {
            log_printf( &logger, " Battery re-charge is needed\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_DIETEMPHIGHCHGPAUSED )
        {
            log_printf( &logger, " Charging stopped due Die Temp high.\r\n" );
        }
        if ( charge_status & PMIC_CHARGE_STATUS_SUPPLEMENTACTIVE )
        {
            log_printf( &logger, " Supplement Mode Active\r\n" );
        }
        log_printf( &logger, " -----------------------------\r\n" );
    }
}
// ------------------------------------------------------------------------ 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.