Using nPM1300 Battery Charger and Power Rails
- 1 1. Overview
- 2 2. SOM-nRF9151 Power Architecture
- 3 3. Configuring nPM1300 PMIC in Zephyr BSP
- 4 4. Controlling nPM1300 PMIC in User Application
- 5 5. Validating nPM1300 PMIC Operations
This application note describes how to configure nPM1300 PMIC in Zephyr BSP and use it in the user application.
The power architecture of the nRF9151 SOM is based on the NORDIC Semiconductor nPM1300 PMIC, which has several power and system management features:
System regulator (SYSREG) of the PMIC supplies main power rail VSYS from:
VBUS (VIN from an AC wall adapter or a USB port- if/when they are present);
Battery (VBAT_C): when a battery is connected but VIN (VBUS) isn’t present;
The VSYS voltage is 4V-5.5V when it is supplied from the VIN (VBUS) (+5V power is present) and 3.2V-4.4V when it is supplied from the Battery/VBAT_C (+5V power isn’t present)
Two 200mA BUCK regulators:
§ BUCK2 (VOUT2) @ 3.0V is used on the SOM and broken out to the SOM interface connectors;
§ BUCK1 is disabled by default, may be enabled and configured by software to a 1.0V-3.0V output voltage. It is available on SOM interface connectors;
Two LDO/Load Switches :
§ LDO1/LSW1 gets power from the BUCK1 output. LDO1/LSW1 is disabled by default, may be enabled and configured by software to a 1.0V-3.0V output voltage. It is available on the SOM interface connectors;
§ LDO2/LSW2 isn’t used in the nRF9151 SOM
SYSREG provide the following features:
Operating voltage up to 5.5 V
Overvoltage protection to 22 V
Undervoltage detection
USB port detection and a current limiter to comply with the USB specification
Provides VBUSOUT voltage
In the nRF9151 SOM, the nPM1300 supplies VBUSOUT voltage on the SOM interface connectors when VIN (VBUS) voltage is present. VBUSOUT provides overvoltage and undervoltage protection for safe connection to external devices.
The nPM1300 supports the USB PD Configuration Channel functionality.
The PMIC VIN (VBUS) input current limiter manages VIN (VBUS) current limitation and charger detection for USB Type-C compatible chargers. The VIN (VBUS) current limit value is configurable by software.
The PMIC battery charger is suitable for general purpose applications with lithium-ion (Li-ion), lithium-polymer (Li-poly), and lithium iron phosphate (LiFePO4) batteries.
nPM1300 supports charging up to 800 mA and delivers up to 500 mA of adjustable regulated voltage.
For more details about the SOM-NRF9151 hardware and power architecture refer to https://voxelbotics.atlassian.net/wiki/x/GQAcKw.
The nPM1300 PMIC device is declared in nrf9151som_nrf9151_ns.dts as a child node of the i2c1 bus:
&i2c1 {
status = "okay";
...
npm1300_pmic: pmic@6b {
compatible = "nordic,npm1300";
reg = <0x6b>;
status = "okay";
host-int-gpios = <&gpio0 10 0>;
pmic-int-pin = <0>;
...
};
};This node configures the following parameters:
Parameter | Value | Description |
|---|---|---|
|
| Enables the |
|
| nPM1300 slave address on the I2C bus, which will be used by the driver to communicate with the PMIC. |
|
| Host SoC GPIO, that will be used for PMIC interrupts. |
|
| nPM1300 interrupt pin. |
The nPM1300 Battery Charger device is declared in nrf9151som_nrf9151_ns.dts as a child node of the npm1300_pmic device:
npm1300_pmic: pmic@6b {
compatible = "nordic,npm1300";
...
npm1300_charger: charger {
compatible = "nordic,npm1300-charger";
term-microvolt = <4200000>;
term-current-percent= <10>;
current-microamp = <500000>;
dischg-limit-microamp = <1340000>;
vbus-limit-microamp = <1200000>;
dietemp-stop-millidegrees = <95000>;
dietemp-resume-millidegrees = <80000>;
thermistor-ohms = <10000>;
thermistor-beta = <3435>;
charging-enable;
};
...
};The devicetree node configures the following parameters:
Parameter | Value | Description |
|---|---|---|
|
| Enables the |
|
| Charge termination voltage in uV. The battery charging mode will switch to constant voltage charge once the battery voltage reaches this value. |
|
| Termination current, as a percentage of current-microamp. Charge completes when the charge current falls below this value. |
|
| Charge current in uA. |
|
| Battery discharge current limit in uA. |
|
| VBUS current limit in uA. |
|
| Battery charging stops when the nPM1300 chip temperature reaches this threshold (in milli-degrees). |
|
| If stopped, battery charging will resume when the nPM1300 chip temperature drops below this threshold (in milli-degrees). |
|
| Thermistor nominal resistance type in ohms. |
|
| Beta value of selected thermistor. |
|
| Enable charging. |
The battery parameters are defined for EEMB LP653042 820 mAh battery:
If another battery is used, the parameters should be changed accordingly.
The nPM1300 regulator device is declared in nrf9151som_nrf9151_ns.dts as a child node of the npm1300_pmic device:
npm1300_pmic: pmic@6b {
compatible = "nordic,npm1300";
...
npm1300_regulators: regulators {
compatible = "nordic,npm1300-regulator";
status = "okay";
/* limits are set to min/max allowed values */
npm1300_buck1: BUCK1 {
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
};
npm1300_ldsw1: LDO1 {
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3000000>;
regulator-initial-mode = <NPM1300_LDSW_MODE_LDSW>;
regulator-allowed-modes = <NPM1300_LDSW_MODE_LDSW>;
};
};
...
};The devicetree node configures the following parameters and subnodes:
Parameter | Value | Description |
|---|---|---|
|
| Enables the |
| ||
|
| Smallest voltage consumers may set. |
|
| Largest voltage consumers may set. |
| ||
|
| Smallest voltage consumers may set. |
|
| Largest voltage consumers may set. |
|
| Initial operating mode. |
|
| List of operating modes that software is allowed to configure for the regulator at run-time. |
The Customized Asset Tracker v2 application implements the following C-binding helper API for nPM1300 battery charger, defined in pmic_charger.* and pmic_soc.* files:
Function | Description | Comments |
| ||
| Get battery voltage from PMIC charger driver. |
Returns 0 on success, or a negative error code on failure. |
| Get battery current from PMIC charger driver. |
Returns 0 on success, or a negative error code on failure. |
| Get battery temperature from PMIC charger driver. |
Returns 0 on success, or a negative error code on failure. |
| Read PMIC charger status register. |
Returns 0 on success, or a negative error code on failure. |
| Read PMIC charger error register. |
Returns 0 on success, or a negative error code on failure. |
| Clear PMIC charger error register. | Returns 0 on success, or a negative error code on failure. |
| Check if charging is enabled. |
Returns 0 on success, or a negative error code on failure. |
| ||
| Calculate battery State of Charge (SoC). |
Returns 0 on success, or a negative error code on failure. |
| Monitor battery State of Charge (SoC). | Schedules a system workqueue task that will periodically update the battery State of Charge. Returns 0 on success, or a negative error code on failure. |
| Emulate battery State of Charge (SoC). |
|
The Customized Asset Tracker v2 application provides a Zephyr system workqueue task that updates the battery State of Charge with 1 minute period and generates an appropriate event, which is distributed by the Application Event Manager and handled by other modules. Refer to https://voxelbotics.atlassian.net/wiki/spaces/SOMnRF9151/pages/802750516/Using+nPM1300+Battery+Charger+and+Power+Rails#3.4.-PMIC-Events for details about PMIC events.
The Customized Asset Tracker v2 application provides a set of Zephyr shell commands for nPM1300 battery charger, defined in the pmic_charger.c file:
Command | Parameters | Comments |
|
| Prints out the battery charger parameters to the serial console in the following format: pmic_charger status
Battery charging: <enabled|disabled>
Battery voltage: <voltage> V
Battery current: <current> mA
Battery temp: <temperature>
Battery SoC: <SoC>
<Charge status>
<Errors> |
|
| Emulate VBUS events. |
|
| Emulate battery SoC. |
The Customized Asset Tracker v2 application implements the following C-binding helper API for nPM1300 voltage regulator, defined in pmic_regulator.* files:
Function | Description | Comments |
| Deinitialize PMIC voltage regulators. |
|
| Enable a specific regulator. |
Returns zero on success, otherwise a negative error code is returned. |
| Disable a specific regulator. |
|
| Check if regulator is enabled. |
Returns true if regulator is enabled, false otherwise.. |
The Customized Asset Tracker v2 application provides a set of Zephyr shell commands for nPM1300 voltage regulator, defined in the pmic_regulator.c file:
Command | Parameters | Comments |
|
| Prints out the BUCK1 and LDSW1 parameters to the serial console in the following format: uart:~$ pmic_regulator status
Regulator: BUCK1 status: <enabled|disabled>, voltage: <voltage> V
Regulator: LDSW1 status: <enabled|disabled>, voltage: <voltage> V |
|
| Enable a specific regulator. |
|
| Disable a specific regulator. |
The Customized Asset Tracker v2 application implements the following C-binding helper API for nPM1300 interrupts, defined in pmic_irq.* files:
Function | Description | Comments |
| Enable PMIC interrupts and configure IRQ handler. | Zero on success, otherwise a negative error code is returned. |
| Disable PMIC interrupts and remove IRQ handler. | |
| Send PMIC event. |
Refer to https://voxelbotics.atlassian.net/wiki/spaces/SOMnRF9151/pages/802750516/Using+nPM1300+Battery+Charger+and+Power+Rails#3.4.-PMIC-Events for details about PMIC events. |
The Customized Asset Tracker v2 application configures the following PMIC interrupts through the mfd_npm1300.c driver:
Interrupt | Description |
| Charging completed. |
| Charging error. |
| The battery is connected to the SOM-NRF9151 baseboard and VBAT voltage is detected. |
| The battery is diconnected from the SOM-NRF9151 baseboard . |
| The battery voltage dropped below 95% of the charge termination voltage while the device is connected to a power source with a USB-C cable. Recharge is needed. |
| The device has been connected to a power source with a USB-C cable and VBUS voltage is detected. |
| The device has been disconnected from a power source. |
The Customized Asset Tracker v2 application configures and handles PMIC interrupts the following way:
PMIC interrupts are configured at Zephyr boot by calling
pmic_irq_enable()insetup()function, defined inutil_module.c.pmic_irq.cfile defines the PMIC interrupt handler, which generates an appropriate PMIC event when the interrupt is triggered. Refer to for details about PMIC events.