<?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>TWIM drivers don&amp;#39;t work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98672/twim-drivers-don-t-work-with-power-management-runtime-enabled</link><description>Hello. I&amp;#39;m trying to get my I2C peripheral (I2C1) working with Zephyr&amp;#39;s Power Management feature. If I make my i2c1 peripheral compatible with &amp;quot;nordic,nrf-twi&amp;quot; the driver works, but the driver does not support Zephyr&amp;#39;s CONFIG_PM functionality. 
 If I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 28 Apr 2023 13:26:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98672/twim-drivers-don-t-work-with-power-management-runtime-enabled" /><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/423007?ContentTypeID=1</link><pubDate>Fri, 28 Apr 2023 13:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f2042c5-7a10-4565-86d3-9d094181e5a0</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;I wasn&amp;#39;t able to reproduce the issue myself, but I only call the I2C transfer functions from the main thread, not from a driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;One possible issue could be that the I2C calls are blocking, and blocking calls can not be used if you are in an ISR. Is there any chance that you are trying to suspend or resume your driver from an ISR, or from a callback that is running in an interrupt context?&lt;/p&gt;
&lt;p&gt;Would you be able to share your test code with me so I can try and reproduce the issue on my side?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume the issue can be reproduced without having the right I2C slave on the bus.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/421938?ContentTypeID=1</link><pubDate>Mon, 24 Apr 2023 07:09:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58d21463-51b6-4c2a-b8fa-525a0894daff</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;I tried to recreate your issue last week, but so far I haven&amp;#39;t been able to do so. I will have to spend some more time on this and get back to you in a day or two with an update.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/421570?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2023 17:15:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:221bb1c0-4992-42ac-8962-b7dd47d82fb1</guid><dc:creator>RobHel</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I do have both CONFIG_PM_DEVICE and CONFIG_PM_DEVICE_RUNTIME enabled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When I use the twi driver (not twim), my I2C calls work as expected. See the image below.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/twi_5F00_driver.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I use the twim driver (not twi), the I2C calls never seem to work. See the image for an I2C read.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/twim_5F00_driver_5F00_nopm.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The twim driver behaves the same with CONFIG_PM_DEVICE and CONFIG_PM_DEVICE_RUNTIME both enabled and both disabled.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would like to use the twim driver because it has built in support for PM, whereas the twi driver does not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What could I be doing wrong that prevents the twim driver from reading / writing as expected? I only have one peripheral on the I2C bus, and the HW is validated as shown with the twi driver.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/421031?ContentTypeID=1</link><pubDate>Tue, 18 Apr 2023 12:34:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:862d7eda-9043-464d-ac89-dc60498e3a2c</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;Do you have both CONFIG_PM_DEVICE and CONFIG_PM_DEVICE_RUNTIME enabled in your project configuration?&lt;/p&gt;
&lt;p&gt;I checked with the developer, and he confirmed that the nrfx_twim driver is tested with PM enabled. It should automatically go to sleep if it is not used.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Does the issue occur at any particular point in your application?&lt;/p&gt;
&lt;p&gt;If you comment out the I2C calls inside the&amp;nbsp;lp5030_pm_action(..) function, will the issue still occur?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420557?ContentTypeID=1</link><pubDate>Fri, 14 Apr 2023 15:04:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a18023dd-34c1-490c-9e1d-c08629c308e0</guid><dc:creator>RobHel</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for catching that. It didn&amp;#39;t solve the overall problem, however. Attached is my lp5030 driver. It&amp;#39;s the only peripheral on the I2C bus.&lt;/p&gt;
&lt;p&gt;Thanks in advance.&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lp5030.c"&gt;devzone.nordicsemi.com/.../lp5030.c&lt;/a&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lp5030_5F00_regs.h"&gt;devzone.nordicsemi.com/.../lp5030_5F00_regs.h&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/lp5030.h"&gt;devzone.nordicsemi.com/.../lp5030.h&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420546?ContentTypeID=1</link><pubDate>Fri, 14 Apr 2023 14:28:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e3d237c-c233-4ad9-9a98-609c38962bd1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;You should be able to drag drop files into the message box directly, or click &lt;em&gt;Insert -&amp;gt; Image/video/file&lt;/em&gt; at the bottom.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to share a lot of files it is best to zip them first.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you mentioned the PM action handler I assume you are writing your own driver. Looking at the overlay you shared earlier I notice you include &amp;quot;.yaml&amp;quot; in the compatible property, which I think you should remove. The property should just be the company and driver name: &amp;quot;ti,lp5030&amp;quot;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Once you share the files I will take a closer look.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420351?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 22:25:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89b364e9-967d-4de4-8e80-d054c47e5166</guid><dc:creator>RobHel</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t believe anything is happening in an interrupt context.&amp;nbsp;I can&amp;#39;t find a way to attach my .c file for you to view.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;On init, the PM action handler function gets called to init the device. In my PM action handler, when entering the case for the action&amp;nbsp;PM_DEVICE_ACTION_RESUME, I do an I2C write. This happens immediatly upon startup. I can confirm this .c file is being initialized after and PM and I2C low level drivers. This I2C write is never successful and I have an assertion in my code to catch this unsuccessful write.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why would this be the case? By the way, I can test the I2C writing and reading seperatly using the shell and it works, but doesn&amp;#39;t seem to work in the PM action handler function. Is this expected?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Rob&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420293?ContentTypeID=1</link><pubDate>Thu, 13 Apr 2023 14:17:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9560b8a3-f80e-4e1e-8807-75c5ad8af724</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Rob&lt;/p&gt;
&lt;p&gt;How are you using the driver from your application?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there any chance you are calling driver functions from an interrupt?&amp;nbsp;&lt;br /&gt;(keeping in mind that many of the callbacks triggered by various libraries will run in interrupt context)&lt;/p&gt;
&lt;p&gt;I am not aware of any issues using the nrfx_twim driver when you have PM enabled, at worst it should just ignore any PM commands, but I can take a look at the implementation if you can confirm whether or not the driver is called from an interrupt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420060?ContentTypeID=1</link><pubDate>Wed, 12 Apr 2023 22:05:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8e80997-6463-49d1-8984-75b1af5d75e1</guid><dc:creator>RobHel</dc:creator><description>&lt;p&gt;The pointer to dev_data gets corrupted in the&amp;nbsp;i2c_nrfx_twim_transfer function. See the below two images when the completion_sync sem is valid and when it is not.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1681337096255v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1681337103468v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: TWIM drivers don't work with power management runtime enabled</title><link>https://devzone.nordicsemi.com/thread/420056?ContentTypeID=1</link><pubDate>Wed, 12 Apr 2023 20:47:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74fef46a-fc17-4499-862c-8e11afc65069</guid><dc:creator>RobHel</dc:creator><description>&lt;p&gt;To add onto this, I can confirm the dev_data-&amp;gt;completion_sync semaphore is getting corrupted. At line 60 in i2c_nrfx_twim.c, it is correct with a count of zero and a limit of 1 as shown below.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1681332427430v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, at line 153 the count and limit are clearly corrupted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1681332472409v2.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>