<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/120140/npm1300-configuration</link><description>Hi, 
 I would like your support in reviewing and helping define the correct configuration for the NPM1300 charger in our application. 
 Here is the current configuration we are using: 
 
 
 
 
 We are using the following battery: renata ICP621333PA-01</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Apr 2025 12:52:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/120140/npm1300-configuration" /><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/532354?ContentTypeID=1</link><pubDate>Tue, 22 Apr 2025 12:52:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba95ed69-0b8d-4c99-9464-63cd9e0e95c1</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;Not really, at list in the meanwhile.&lt;/p&gt;
&lt;p&gt;What is strange, is that immediately after the device_is_ready, there are 1 or more api function that uses I2C and works fine, without any failures. so ironically removing this function solved it, and the frequent failures we had disappeared.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;While I would love to analyze and debug it farther, for now this solution satisfies us, and I&amp;#39;m forced to focus on other burning issues.&lt;/p&gt;
&lt;p&gt;Did anyone report on similar issues before? Can upgrading to ncs 2.9.0 fix this issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/532349?ContentTypeID=1</link><pubDate>Tue, 22 Apr 2025 12:45:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b75cfffe-6a71-457d-a1a0-21ad129b8b7a</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;The device_is_ready function does communicate via I2C. So if it fails, then there is reason to believe that it may fail at a later point.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you were able to reproduce it on a DK, then I could reproduce it here on my desk, or even forward it to our PMIC team, which could analyze it.&amp;nbsp;&lt;/p&gt;
[quote user="levijo"]&lt;p&gt;We have the same issue with the IMU driver as well but much less often than the fuelgague.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;That could be related. Perhaps some collission/HW issues.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So while the device_is_ready() is not strictly needed, the fact that it sometimes returns an error indicates that something is not correct. Do you see any other issues with the PMIC? Some bad/weird battery measurements?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/532190?ContentTypeID=1</link><pubDate>Sun, 20 Apr 2025 15:34:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3dae01cc-901d-4e6b-8ee6-cff43d2c1be8</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;I&amp;#39;m using a PCB where it is more difficult to analyze I2C wires.&lt;/p&gt;
&lt;p&gt;Does device_is_ready function communicate with the device via i2c to verify the device communication? to my understanding it does not, so I don&amp;#39;t see how this is related.&lt;/p&gt;
&lt;p&gt;using the DK is not possible as we don&amp;#39;t have those peripherals connected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/531669?ContentTypeID=1</link><pubDate>Mon, 14 Apr 2025 10:14:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c63ba031-42f2-404b-8bf4-939f9e8bc209</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="levijo"]so, the part that is failing is device_is_ready(fuelgauge_device) function returns sometimes false. statistically its one out a few resets process. Unfortunately, this happens although the device is ready, and removing this check solves the problem. We have the same issue with the IMU driver as well but much less often than the fuelgague.[/quote]
&lt;p&gt;So sometimes the device_is_ready() fails, and sometimes there are issues with the IMU driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you please try to attach a logic analyzert to your nPM I2C GPIOs, and check if the behavior changes when it succeeds and when it doesn&amp;#39;t?&lt;/p&gt;
&lt;p&gt;Are you using a DK and an nPM evaluation kit? Or do you have a PCB where it is difficult to analyse the I2C wires?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Are you able to reproduce the issue on an nRF5340DK and an nPM1300 Evaluation kit? If so, is it possible to upload an application that can reproduce the issue that you are seeing?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/531587?ContentTypeID=1</link><pubDate>Sat, 12 Apr 2025 14:23:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bbfd56f-3806-4f72-a0de-520460a8abc8</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;so, the part that is failing is device_is_ready(fuelgauge_device) function returns sometimes false. statistically its one out a few resets process. Unfortunately, this happens although the device is ready, and removing this check solves the problem. We have the same issue with the IMU driver as well but much less often than the fuelgague.&lt;/p&gt;
&lt;p&gt;So, I&amp;#39;m wondering, is this check redundant? what is good for? should I remove this check for all of the drivers (we have quite a few of those checks)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/531368?ContentTypeID=1</link><pubDate>Thu, 10 Apr 2025 13:06:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:052ed7ae-a319-435e-96f1-d643bdffeab6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Are you able to see what part of this function that returns an error? Perhaps if you assign different return values for the different checks (for debugging purposes), and print the return value after the&amp;nbsp;hal_fg_init() has returned? Which check is it that fails?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/531065?ContentTypeID=1</link><pubDate>Tue, 08 Apr 2025 15:30:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93259c77-476b-4987-920c-56df9199361d</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;Thank Edvin, this seems to work well!&lt;/p&gt;
&lt;p&gt;I have another issue related to the npm1300 driver. occasionally this function - hal_fg_init() returns false.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there a problem in this function? I also tried a retry mechanism on this function, but when it fails, it always fail until the next reboot.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int hal_fg_init(void)
{
    struct sensor_value value;
    struct nrf_fuel_gauge_init_parameters parameters = {
        .model = &amp;amp;battery_model,
        .opt_params = NULL,
    };
    int32_t chg_status;
    bool found = false;

    if (fuelgauge_device != NULL) {
        LOG_INF(&amp;quot;fuel gauge HAL already initialized&amp;quot;);
        return 0;
    }

    LOG_INF(&amp;quot;initialize NPM1300 fuel gauge HAL (version: \&amp;quot;%s\&amp;quot;, battery: \&amp;quot;%s\&amp;quot;)&amp;quot;,
            nrf_fuel_gauge_version, battery_model.name);

    fuelgauge_device = DEVICE_DT_GET(FUELGAUGE_CONTROLLER0_NODE);
    if (fuelgauge_device) {
        if (device_is_ready(fuelgauge_device)) {
            LOG_INF(&amp;quot;found fuel gauge controller \&amp;quot;%s\&amp;quot;&amp;quot;, fuelgauge_device-&amp;gt;name);
            found = true;
        } else {
            LOG_ERR(&amp;quot;Fuel gauge controller \&amp;quot;%s\&amp;quot; is not ready&amp;quot;, fuelgauge_device-&amp;gt;name);
        }
    }

    if (found == false) {
        LOG_ERR(&amp;quot;no fuel gauge controller found&amp;quot;);
        return -1;
    }

    if (read_npm1300_fuelgauge(fuelgauge_device, &amp;amp;parameters.v0, &amp;amp;parameters.i0, &amp;amp;parameters.t0,
                               &amp;amp;chg_status) &amp;lt; 0) {
        return -1;
    }

    /* Store charge nominal and termination current, needed for ttf calculation */
    sensor_channel_get(fuelgauge_device, SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT, &amp;amp;value);
    max_charge_current = (float)value.val1 + ((float)value.val2 / 1000000);
    term_charge_current = max_charge_current / 10.f;

    nrf_fuel_gauge_init(&amp;amp;parameters, NULL);

    ref_time = k_uptime_get();

    if (configure_npm1300_events() &amp;lt; 0) {
        return -1;
    }

    return 0;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/530830?ContentTypeID=1</link><pubDate>Mon, 07 Apr 2025 13:12:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85c7aab3-7aac-45f6-ba05-2d95a486bb2d</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Our PMIC team commented on the discharge limit was a bit high. Try setting it to 240mA.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/530709?ContentTypeID=1</link><pubDate>Sun, 06 Apr 2025 06:24:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50051fd8-bce2-4434-8a46-efce9801f3cd</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;thanks I will try it and see if this works.&lt;/p&gt;
&lt;p&gt;regarding the first question I asked, about the correct battery configuration settings, I used chatGPT to help me with that.&lt;/p&gt;
&lt;p&gt;can you review it here and let me know if its OK? It would be helpful to have a professional set of eyes to approve it:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://chatgpt.com/share/67f21a09-60ec-8001-95c5-2149c9cc0a10"&gt;chatgpt.com/.../67f21a09-60ec-8001-95c5-2149c9cc0a10&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/530632?ContentTypeID=1</link><pubDate>Fri, 04 Apr 2025 13:11:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3850500b-a5a3-47bc-9b11-3b730b2b4b22</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply!&lt;/p&gt;
&lt;p&gt;There were some issues detecting the VBUS status register in some NCS versions, and I believe this was present on v2.7.0.&lt;/p&gt;
&lt;p&gt;I suggest that on startup, you check the register directly, and then use the events to be notified on changes on the USB connection.&lt;/p&gt;
&lt;p&gt;You can read the register using this snippet:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/drivers/sensor/nordic/npm1300_charger/npm1300_charger.c#L301"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.6.99-ncs2/drivers/sensor/nordic/npm1300_charger/npm1300_charger.c#L301&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ret = mfd_npm1300_reg_read(config-&amp;gt;mfd, VBUS_BASE, VBUS_OFFSET_STATUS, &amp;amp;data-&amp;gt;vbus_stat);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Alternatively, you can read it more directly like it is done here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.7.0/samples/pmic/native/npm1300_one_button/src/main.c#L64-L72"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.7.0/samples/pmic/native/npm1300_one_button/src/main.c#L64-L72&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	if (pins &amp;amp; BIT(NPM1300_EVENT_VBUS_DETECTED)) {
		printk(&amp;quot;Vbus connected\n&amp;quot;);
		vbus_connected = true;
	}

	if (pins &amp;amp; BIT(NPM1300_EVENT_VBUS_REMOVED)) {
		printk(&amp;quot;Vbus removed\n&amp;quot;);
		vbus_connected = false;
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/529202?ContentTypeID=1</link><pubDate>Thu, 27 Mar 2025 06:53:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:316bd6ed-c673-4f33-afc9-ebf45214575b</guid><dc:creator>levijo</dc:creator><description>&lt;p&gt;we are using NCS version 2.7.0.&lt;/p&gt;
&lt;p&gt;this function is called in boot and returns the usb connection status on init:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int battery_init(void)
{
    if (hal_fg_init() != 0) {
        LOG_ERR(&amp;quot;failed to initialize fuel gauge HAL&amp;quot;);
        return -1;
    } else {
        hal_fg_register_events_cb(charger_event_cb);
    }
    battery_info.flags.is_charger_connected = 0;
    battery_info.flags.is_full = 0;
    battery_info.flags.is_critical_level = 0;
    battery_info.flags.is_low_level = 0;
    battery_info.flags.unused = 0;

    if(battery_update_info() &amp;lt; 0) {
        return -1;
    }
    if(hal_fg_charger_connected()) {
        battery_info.flags.is_charger_connected = 1;
    }
    return 0;
}

bool hal_fg_charger_connected(void)
{
    struct sensor_value val;
    bool connected;
    int ret;

    ret = sensor_attr_get(fuelgauge_device, SENSOR_CHAN_CURRENT, SENSOR_ATTR_UPPER_THRESH, &amp;amp;val);
    if (ret &amp;lt; 0) {
        LOG_ERR(&amp;quot;failed to read npm1300 current&amp;quot;);
        return false;
    }

    connected = (val.val1 != 0) || (val.val2 != 0);

    if (!connected) {
        /* the SENSOR_CHAN_CURRENT attr is not working properly so this code is needed.
         remove when npm1300 charger driver fix this issue. */
        float avg_current_mA;

        ret = hal_fg_get_data(NULL, &amp;amp;avg_current_mA, NULL, NULL);
        if (ret &amp;lt; 0) {
            return false;
        }
        connected = (avg_current_mA &amp;lt; 0);
    }

    return connected;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nPM1300 Configuration</title><link>https://devzone.nordicsemi.com/thread/529159?ContentTypeID=1</link><pubDate>Wed, 26 Mar 2025 21:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48007737-206e-4077-a89f-1a96ad465065</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;From the first glance, the disttcharge limit (1.34 A) seems too high for such a small battery. The battery datasheet recommends to stay within 1C (240mA) or 2C bursts/non-continuous (480mA).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As for the USB detection issue, it is difficult to say without more information. First, what NCS version are you using? For a while we had some issues properly exposing the VBUS status register via the charger API, and the USB detection relied on interrupts.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you have any code snippets and logs to share, so that we can look into this? Particularly related to the start of the application, where the 0% value comes from.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>