<?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>npmx drivers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/125848/npmx-drivers</link><description>I am using a STM32 with the NPMX drivers. 
 
 I am having a few issues and wanted to see if there are recommendations. 
 Issue 1: 
 disabling the interrupts does not seem to work 
 
 
 the above code comes from the PORTING Guide. 
 when i run that block</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Dec 2025 09:54:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/125848/npmx-drivers" /><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/557414?ContentTypeID=1</link><pubDate>Fri, 19 Dec 2025 09:54:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:363a69d1-4267-47af-87a5-0df36ab31ec4</guid><dc:creator>SergeiOv</dc:creator><description>&lt;p&gt;Is the fuel_gauge_update() function you&amp;#39;re referring to was copied from the fuel_gauge sample in the npmx-zephyr repository? I&amp;#39;ll base my answer on this assumption.&lt;/p&gt;
&lt;p&gt;If you look at the function, you can see that it does multiple things:&lt;br /&gt;1. Get (this involves npmx driver/I2C) and report &lt;strong&gt;VBUS&lt;/strong&gt; state to the fuel gauge library&lt;br /&gt;2. Get (npmx/I2C) and report &lt;strong&gt;Charger&lt;/strong&gt; state to the fuel gauge library&lt;br /&gt;3. Get the &lt;strong&gt;ADC&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;results&lt;/strong&gt; (npmx/I2C)&lt;br /&gt;4. &lt;strong&gt;Trigger VBAT/IBAT, trigger NTC&lt;/strong&gt; measurements (npmx/I2C). Yes, in this order, that&amp;#39;s why we trigger the very first measurement before we init fuel gauge in the sample (see main.c)&lt;br /&gt;5. Call nrf_fuel_gauge_process() with the gotten results.&lt;/p&gt;
&lt;p&gt;As you see, there&amp;#39;s a lot of I2C communication involved in this function call. Since you have a dedicated ADC task in your program, I don&amp;#39;t recommend to blindly copy this function. There is no point in having an automatically triggered ADC configuration with a pin interrupt on measurement result readiness and then manually trigger the measurements again in the fuel_gauge_update() function.&lt;/p&gt;
&lt;p&gt;Overall, the samples are just that - they are sample code. They are intended to show examples of how different PMIC components could be used in an application. They are a good starting point for development, but you cannot treat their functions (like fuel_gauge_update in this case) as some sort of library code. This is just a reference implementation which &lt;em&gt;must&lt;/em&gt; be adapted to your needs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/557357?ContentTypeID=1</link><pubDate>Thu, 18 Dec 2025 16:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67c6b021-d66d-4ab9-a7f4-11a58f83fba4</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;Sergei;&lt;/p&gt;
&lt;p&gt;Thanks for the response.&lt;/p&gt;
&lt;p&gt;The interrupt is edge driven.&amp;nbsp; I disable it when i enter the ISR and enable it after the call to npmx_core_proc().&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My 1st thread seems to be working fine.&lt;/p&gt;
&lt;p&gt;the issue is the 2nd thread.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;it finished the fule_gauge_update() and hangs int he 2nd thread.&amp;nbsp; never exiting.&lt;br /&gt;I will continue to work on that.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;but one question i have is that i enable the GPIO interrupt on the nPM1300 for the ADC, Changer, USB, Battery.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;but it looks like the Fuel_gauge is using a polling event system.&amp;nbsp; is this true?&amp;nbsp; Is this causing an issue between the 2?&amp;nbsp; should i disable the interrupts for the adc, usb, ... when i exit thread one then enable them again when i enter?&lt;/p&gt;
&lt;p&gt;I am stepping through the code, but I am still trying to get a grasp on what is going on.&lt;/p&gt;
&lt;p&gt;I will be on vacation until January, so I will get back to this then.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Again I appreciate your help&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/557195?ContentTypeID=1</link><pubDate>Wed, 17 Dec 2025 11:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:007c4f87-a5f9-40d2-8e43-745f0c710008</guid><dc:creator>SergeiOv</dc:creator><description>&lt;p&gt;Is the interrupt level- or edge-triggered?&lt;/p&gt;
&lt;p&gt;Level-triggered: you should get another interrupt automatically if another event occurred while processing the current events. No additional logic should be needed in this case besides setting the flag in the interrupt handler and disabling the interrupt source until after you have called the processing function. Then it needs to be re-enabled.&lt;br /&gt;Edge-triggered: the interrupt source doesn&amp;#39;t have to be disabled here, but the processing function must be called until the interrupt pin is in the inactive state AND the flag is false. Only ensuring this, the interrupt will be able to fire again.&lt;br /&gt;I would recommend using the first option. I don&amp;#39;t see you re-enabling the interrupt after you call&amp;nbsp;npmx_core_proc. Something to look into.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As for the potential concurrency issues, I don&amp;#39;t have much experience with FreeRTOS to recommend anything specific, but some things to look into are:&lt;br /&gt;Are threads preemptive or cooperative? If a thread can be preempted, you need to ensure that the I2C access is exclusive to prevent any issues there, e.g. with a mutex.&lt;br /&gt;Same goes for interrupt handlers. Ideally they should not do any I2C activity at all. But from your description it already seems to be the case.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The time required to read out the ADC conversion results would depend on your I2C bus frequency. Generally, it is just a few milliseconds. The fuel gauge process function should take even less.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Overall, guessing the source of the issues here is maybe not the best approach. Are you able to just attach a debugger to your program and do some investigations that way?&lt;br /&gt;And without seeing any of the actual code you&amp;#39;re writing I&amp;#39;m not able to do more specific suggestions here. There is no one correct way to configure everything on the PMIC, this would largely depend on the use case. But there are definitely wrong ways to do that, which would be much easier to identify having code at hand.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/557102?ContentTypeID=1</link><pubDate>Tue, 16 Dec 2025 14:32:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d91a421-ce2c-4f1b-be7c-3eb5c4654319</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;A new update.&amp;nbsp; I have the Fuel Gauge responding with actual data.&amp;nbsp;&amp;nbsp;&lt;br /&gt;I am still having the issue with Task o1 only responding with the battery voltage once.&amp;nbsp; but now I have the code getting trapped in task 2.&amp;nbsp;&amp;nbsp;&lt;br /&gt;I guess I need to understand the configuration of the PMIC to correctly operate.&amp;nbsp;&lt;br /&gt;I have the PMIC generating an interrupt on events from the battery, USB, and charger.&amp;nbsp; this event toggles a gpio that sets a flag in the STM ISR that is read by a task to run the npmx_core_interrupt() and npmx_Core_proc() functions.&amp;nbsp; &lt;br /&gt;is this the correct way to do it?&amp;nbsp; how should I configure the PMIC to guarantee the works correctly? (ADC settings, Event settings, ..)?&lt;br /&gt;&lt;br /&gt;I am not sure why the Fuel gauge only responds once and holds the device in the second task.&amp;nbsp; is there a specific config that is needed that is conflicted with how i set up for the other task?&lt;br /&gt;I have been testing for a while, but not making much progress.&amp;nbsp; any thought are helpful&amp;nbsp;&lt;br /&gt;thanks&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/556476?ContentTypeID=1</link><pubDate>Mon, 08 Dec 2025 14:29:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a09e9825-3d82-49e1-b91a-f66303790567</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;I have everything &amp;quot;working&amp;quot; but i have a few issues and questions.&lt;br /&gt;Let me describe my configuration:&lt;/p&gt;
&lt;p&gt;I have a STM32 running FreeRTOS.&amp;nbsp; I have the PMIC configured for the ADC to automeasure every 1 Second.&amp;nbsp; all USB, VBAT, ADC, Charger will generate an Interrupt on GPIO3 from the PMIC.&lt;br /&gt;The STM has a ISR that simply sets a flag the an interrupt occured.&lt;/p&gt;
&lt;p&gt;I have one thread that runs this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  for(;;)
  {
	printf(&amp;quot;\n myTask01 \n&amp;quot;); //WRC print Task

	if (pmic_interrupt) {
		  npmx_core_interrupt(&amp;amp;npm1300_instance);
		  npmx_core_proc(&amp;amp;npm1300_instance);
		  pmic_interrupt = false;
		  osDelay(1000);
	  }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have a second code that runs the Fuel Gauge&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  for(;;)
  {
	printf(&amp;quot;\n myTask02 \n&amp;quot;); //WRC print Task
	fuel_gauge_update(&amp;amp;npm1300_instance);
	osDelay(1000);
  }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have been playing with thread priorities and delay numbers, but i cant get a consistent result.&lt;/p&gt;
&lt;p&gt;The first task sometimes reports the battery voltage or events if I pull the USB.&amp;nbsp; like this:&lt;/p&gt;
&lt;div style="background-color:#ffffff;padding:0px 0px 0px 0px;"&gt;
&lt;div style="background-color:#ffffff;color:#000000;font-family:&amp;#39;Consolas&amp;#39;;font-size:10pt;white-space:pre-wrap;"&gt;
&lt;p style="margin:0;"&gt;myTask01&lt;/p&gt;
&lt;p style="margin:0;"&gt;Battery: 4125 mV.&lt;/p&gt;
&lt;p style="margin:0;"&gt;State: VBUS_CONNECTED_CHARGING_CC.&lt;/p&gt;
&lt;p style="margin:0;"&gt;State: BATTERY_CONNECTED.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;but most of the time it only prints&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;padding:0px 0px 0px 0px;"&gt;&lt;span style="background-color:#ffffff;color:#000000;font-family:&amp;#39;Consolas&amp;#39;;font-size:10pt;white-space:pre-wrap;"&gt;myTask01 &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;so i know it is entering the task, but not reading the ADC for VBAT.&lt;/p&gt;
&lt;p&gt;either missing the interrupt or the threads are not allotted enough time&lt;/p&gt;
&lt;p&gt;the Fuel Gauge task only prints&lt;/p&gt;
&lt;div style="background-color:#ffffff;padding:0px 0px 0px 0px;"&gt;
&lt;div style="background-color:#ffffff;color:#000000;font-family:&amp;#39;Consolas&amp;#39;;font-size:10pt;white-space:pre-wrap;"&gt;
&lt;p style="margin:0;"&gt;myTask02&lt;/p&gt;
&lt;p style="margin:0;"&gt;Constant current charging&lt;/p&gt;
&lt;p style="margin:0;"&gt;Reading ADC measurements failed.&lt;/p&gt;
&lt;p style="margin:0;"&gt;V: -0.000, I: 0.000, T: -0.00, SoC: 0.00, TTE: nan, TTF: nan&lt;/p&gt;
&lt;p style="margin:0;"&gt;&lt;/p&gt;
&lt;p style="margin:0;"&gt;I guess my questions are&lt;/p&gt;
&lt;p style="margin:0;"&gt;what is the timing needed for each task to complete the PMIC and Fuel Gauge procedures?&lt;/p&gt;
&lt;p style="margin:0;"&gt;any thought on why I always get &amp;quot;adc failed&amp;quot; in the Fuel Gauge?&lt;/p&gt;
&lt;p style="margin:0;"&gt;do i need to configure the ADC different?&lt;/p&gt;
&lt;p style="margin:0;"&gt;&lt;/p&gt;
&lt;p style="margin:0;"&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/556091?ContentTypeID=1</link><pubDate>Wed, 03 Dec 2025 10:15:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3115d1b2-ed18-4ed3-8c72-df821f3c8c07</guid><dc:creator>SergeiOv</dc:creator><description>&lt;p&gt;Good to hear you&amp;#39;ve solved the I2C issues. Yes, using npmx drivers is not very straight-forward as it allows much finer tuning of different parameters, etc. But that&amp;#39;s the appeal of the bare-metal flavour of drivers for many, for simplicity you could use our Zephyr native drivers.&lt;/p&gt;
&lt;p&gt;To help you get through the learning curve on npmx if you continue this way, we have built docs, e.g. here&amp;#39;s the page on ADC since you&amp;#39;re trying to get some measurements now:&amp;nbsp;&lt;a id="" href="https://nordicsemiconductor.github.io/npmx/drivers/adc/index.html"&gt;https://nordicsemiconductor.github.io/npmx/drivers/adc/index.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On the front page of these docs we&amp;#39;ve also linked&amp;nbsp;&lt;a id="" href="https://github.com/NordicSemiconductor/npmx-zephyr"&gt;https://github.com/NordicSemiconductor/npmx-zephyr&lt;/a&gt;&amp;nbsp;where you can find various npmx usage examples. The samples are integrated into the Zephyr environment, but the way the npmx APIs are used does not change based on the environment, so those could be copied (with some adjustments to your use case) if found useful.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/556028?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2025 14:57:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4755aa95-e559-40ae-afd2-6ec05f6e7edd</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;i have the I2C working now.&amp;nbsp; so my only issue is how to use the npmx drivers correctly.&lt;/p&gt;
&lt;p&gt;it turns out I needed to do a conversion from the STM HAL I2C error return status to the npmx_error_t enumeration. so i was returning the correct enum in the I2C read write functions.&lt;/p&gt;
&lt;p&gt;I believe I am starting to understand the nPMX drivers.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;for example, would this be the correct way to enable vbat to auto measure every second in single measurement mode:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Enable VBAT auto measure every 1 second in single measurement mode
    npmx_adc_config_t adc_conf;
    adc_conf.vbat_burst =0;									//Set ADCCONFIG VBAT BURST to SINGLEMODE
    adc_conf.vbat_auto = 1;									//set ADCONFIG VBAT AUTO to Trigger measurement every 1 Second
    npmx_adc_t * adc = npmx_adc_get(&amp;amp;npm1300_instance, 0);
    ret =  npmx_adc_config_set(adc, &amp;amp;adc_conf);&lt;/pre&gt;I have many questions about just the basic order of configuring things and use of correct masks for enabling/disabling charger, creating callbacks correctly, ....&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I guess I will keep&amp;nbsp;trying and&amp;nbsp;open a ticket if I run into issues.&lt;/p&gt;
&lt;p&gt;thanks for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/555995?ContentTypeID=1</link><pubDate>Tue, 02 Dec 2025 12:36:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d104abfa-676a-4874-a7e0-fcbcce8626e8</guid><dc:creator>SergeiOv</dc:creator><description>&lt;p&gt;There is no point in using any of the npmx functions as long as the I2C read/write functions are not properly implemented. If you struggle with the implementation, I could give some guidance based on your current code, or at least a reference to STM32 documentation I should use to implement this.&lt;/p&gt;
&lt;p&gt;&amp;gt; but i only get one read for the ADCCONFIG, but nothing else.&lt;/p&gt;
&lt;p&gt;I suspect that the I2C read function returns an error which makes it the first and the last read as the init function will terminate on any communication error. That&amp;#39;s why I asked you to check the init return code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/555879?ContentTypeID=1</link><pubDate>Mon, 01 Dec 2025 14:08:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:53150ae0-581e-4509-b276-d55ea1837735</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;I am having trouble with the correct STM32 HAL I2C calls for TX and RX.&amp;nbsp; I believe I have the TX working correctly because I call to clear all interrupts and it appears to work.&amp;nbsp; the RX might still be an issue.&amp;nbsp; in the npmx_core_inti() function it looks like it needs to read several registers if you set &amp;quot;Restore Values&amp;quot; to True.&amp;nbsp; but i only get one read for the ADCCONFIG, but nothing else.&amp;nbsp; how many reads of registers should there be?&lt;br /&gt;&lt;span style="background-color:#ffffff;padding:0px 0px 0px 2px;"&gt;&lt;span style="background-color:#ffffff;color:#000000;font-family:&amp;#39;Consolas&amp;#39;;font-size:10pt;white-space:pre;"&gt;&lt;span style="background-color:#d4d4d4;color:#000000;font-weight:bold;"&gt;adc, ntc, charge, discharge, ship.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;Is there any more guidance on the preferred function calls to write to registers? do you &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;padding:0px 0px 0px 2px;"&gt;&lt;span style="background-color:#ffffff;color:#000000;font-family:&amp;#39;Consolas&amp;#39;;font-size:10pt;white-space:pre;"&gt;need to call npmx_xxx_get() for any specific function before calling npmx_xxx_set()?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: npmx drivers</title><link>https://devzone.nordicsemi.com/thread/555537?ContentTypeID=1</link><pubDate>Wed, 26 Nov 2025 15:07:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fad402c-b237-4cfc-b354-fccf414e650d</guid><dc:creator>SergeiOv</dc:creator><description>&lt;p&gt;I would first of all like to see your `my_i2c_write_function` and `my_i2c_write_function` implementations, are you sure they are implemented properly?&lt;/p&gt;
&lt;p&gt;On the first screenshot nothing is happening really. It&amp;#39;s neither a write nor a read transaction. Examples of those you can see in the datasheet&amp;nbsp;&lt;a href="https://docs.nordicsemi.com/bundle/ps_npm1300/page/chapters/core_components/ctrl_reg/doc/frontpage.html#d89e68"&gt;https://docs.nordicsemi.com/bundle/ps_npm1300/page/chapters/core_components/ctrl_reg/doc/frontpage.html#d89e68&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;On the second screenshot it seems to read out the 0x0509 register (ADC_CONFIG) getting value 0. While this can be part of the initialization function, it shouldn&amp;#39;t be the only transaction in this case... Did you check the return code of this function call?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>