<?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>nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94738/nrf52840-low-power-pwm-in-nrf-connect-sdk</link><description>There is a low power pwm in nRF5 SDK. I can not find it in the nRF Connect SDK. Any suggestion how to achieve the same using nRF Connect SDK?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 08 Jan 2023 21:28:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94738/nrf52840-low-power-pwm-in-nrf-connect-sdk" /><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/403701?ContentTypeID=1</link><pubDate>Sun, 08 Jan 2023 21:28:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ba6454c-54b7-47cf-ad20-5c3e0af6411d</guid><dc:creator>pmochocki</dc:creator><description>[quote userid="98146" url="~/f/nordic-q-a/94738/nrf52840-low-power-pwm-in-nrf-connect-sdk/403045"]I will try to update to&amp;nbsp;nRF Connect SDK 2.2.0 during the weekend and let you know if it changes something.[/quote]
&lt;p&gt;Just FYI. I have updated the nRF Conncet SDK to version 2.2.0. I have created the project again and I do not see this strange &amp;quot;error&amp;quot; anymore.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/403223?ContentTypeID=1</link><pubDate>Wed, 04 Jan 2023 15:12:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0ea83c0-fc50-4978-b3d7-cd67155121d6</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="pmochocki"]At this point I will assume this is a minor issue related to VS Code and how it does the on the fly parsing. [/quote]
&lt;p&gt;Yes, that seems likely (although it is a bit strange that I don&amp;#39;t see the same on my end).&lt;/p&gt;
[quote user="pmochocki"]BTW - is there a way to add an offset between PWM cannel 0 and PWM channel 1? I have seen some discussions how to do in the legacy nRF5 SDK, but I do not know how to do it in Zephyr using&amp;nbsp;&lt;span&gt;nRF Connect SDK.&lt;/span&gt;[/quote]
&lt;p&gt;There is no direct support for that. It might be possible to achieve it somehow, but I am not able to suggest anything specific.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/403045?ContentTypeID=1</link><pubDate>Tue, 03 Jan 2023 19:06:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:272cbd54-aa8b-481e-9339-f098db5d14e2</guid><dc:creator>pmochocki</dc:creator><description>&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/eith"&gt;Einar Thorsrud&lt;/a&gt;&amp;nbsp;thank you very much for taking the time and checking it on your end.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/94738/nrf52840-low-power-pwm-in-nrf-connect-sdk/402990"]Can you double check that the overlay files are used?[/quote]
&lt;p&gt;The app.overlay is used - without it I get a build break as the pwm_led1 is undefined.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/94738/nrf52840-low-power-pwm-in-nrf-connect-sdk/402990"]If they are, then you should see that&amp;nbsp;CONFIG_PWM_NRF5_SW=y in build/zephyr/.config[/quote]
&lt;p&gt;I see&amp;nbsp;CONFIG_PWM_NRF5_SW=y&amp;nbsp;&lt;span&gt;in build/zephyr/.config:&lt;/span&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/pastedimage1672771611060v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see I have set&amp;nbsp;CONFIG_PWM_LOG_LEVEL_DBG=y to mimic your settings. I still see the same &amp;quot;error&amp;quot;:&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/pastedimage1672771866789v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;At this point I will assume this is a minor issue related to VS Code and how it does the on the fly parsing. I will try to update to&amp;nbsp;nRF Connect SDK 2.2.0 during the weekend and let you know if it changes something.&lt;/p&gt;
&lt;p&gt;BTW - is there a way to add an offset between PWM cannel 0 and PWM channel 1? I have seen some discussions how to do in the legacy nRF5 SDK, but I do not know how to do it in Zephyr using&amp;nbsp;&lt;span&gt;nRF Connect SDK.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/402990?ContentTypeID=1</link><pubDate>Tue, 03 Jan 2023 14:07:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18417784-2f07-4fb4-a9c8-c88fff97440d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;That is odd. When I test essentially exactly what you did here this works on my end. I get this log:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v3.2.99-ncs1 ***
PWM-based LED fade
[00:00:00.258,728] &amp;lt;dbg&amp;gt; pwm_nrf5_sw: pwm_nrf5_sw_set_cycles: channel 0, period 8, pulse 4
[00:00:00.267,761] &amp;lt;dbg&amp;gt; pwm_nrf5_sw: pwm_nrf5_sw_set_cycles: channel 1, period 8, pulse 4&lt;/pre&gt;showing that the SW implementation is sued, and I can also put a breakpoint in&amp;nbsp;zephyr/drivers/pwm/pwm_nrf5_sw.c to verify that it is the case.&lt;/p&gt;
&lt;p&gt;How does this look in your end? Can you double check that the overlay files are used? If they are, then you should see that&amp;nbsp;CONFIG_PWM_NRF5_SW=y in build/zephyr/.config. Is it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/402874?ContentTypeID=1</link><pubDate>Mon, 02 Jan 2023 21:16:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3aa7df56-369c-4671-b96a-e5ed95895c1b</guid><dc:creator>pmochocki</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/eith"&gt;Einar Thorsrud&lt;/a&gt;&amp;nbsp;unfortunately I need some more support. I am totally new to nRF and Zephyr.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I am using nRF Connect SDK 2.1.2 and the nRF52840 development kit. I have modified the prj.conf file and added&amp;nbsp;CONFIG_PWM_NRF5_SW:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_PRINTK=y
CONFIG_LOG=y

# PWM
CONFIG_PWM=y
CONFIG_PWM_NRF5_SW=y
#CONFIG_PWM_LOG_LEVEL_DBG=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have modified the Fade LED Sample to use two PWM channels:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2016 Intel Corporation
 * Copyright (c) 2020 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file Sample app to demonstrate PWM-based LED fade
 */

#include &amp;lt;zephyr/zephyr.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/pwm.h&amp;gt;

static const struct pwm_dt_spec pwm_led0 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0));
static const struct pwm_dt_spec pwm_led1 = PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1));

#define NUM_STEPS	50U
#define SLEEP_MSEC	1000U

void main(void)
{
	uint32_t period = PWM_KHZ(4);
	uint32_t pulse_width = period / 2;

	//uint32_t pulse_width = 0U;
	//uint32_t step = pwm_led1.period / NUM_STEPS;
	//uint8_t dir = 1U;
	int ret;
	bool state = false;

	printk(&amp;quot;PWM-based LED fade\n&amp;quot;);

	if (!device_is_ready(pwm_led0.dev)) {
		printk(&amp;quot;Error: PWM device %s is not ready\n&amp;quot;,
		       pwm_led0.dev-&amp;gt;name);
		return;
	}

	if (!device_is_ready(pwm_led1.dev)) {
		printk(&amp;quot;Error: PWM device %s is not ready\n&amp;quot;,
		       pwm_led1.dev-&amp;gt;name);
		return;
	}

	while (1) {
		if (state) 
		{
			pulse_width = 0;
			state = false;
		}
		else
		{
			pulse_width = period / 2;
			state = true;
		}

		ret = pwm_set_dt(&amp;amp;pwm_led0, period, pulse_width);
		if (ret) {
			printk(&amp;quot;Error %d: failed to set pulse width\n&amp;quot;, ret);
			return;
		}

		ret = pwm_set_dt(&amp;amp;pwm_led1, period, pulse_width);
		if (ret) {
			printk(&amp;quot;Error %d: failed to set pulse width\n&amp;quot;, ret);
			return;
		}

		k_sleep(K_MSEC(SLEEP_MSEC));
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I have added an app.overlay file to modify the Device Tree:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
	pwmleds {
		compatible = &amp;quot;pwm-leds&amp;quot;;
		pwm_led0: pwm_led_0 {
			pwms = &amp;lt;&amp;amp;sw_pwm 0 PWM_KHZ(4) PWM_POLARITY_INVERTED&amp;gt;;
		};
		pwm_led1: pwm_led_1 {
			pwms = &amp;lt;&amp;amp;sw_pwm 1 PWM_KHZ(4) PWM_POLARITY_NORMAL&amp;gt;;
		};
	};

	aliases {
		pwm-led1 = &amp;amp;pwm_led1;
	};
};

&amp;amp;sw_pwm {
	status =&amp;quot;okay&amp;quot;;
	channel-gpios = &amp;lt;&amp;amp;gpio0 13 GPIO_ACTIVE_LOW&amp;gt;,
					&amp;lt;&amp;amp;gpio0 14 GPIO_ACTIVE_LOW&amp;gt;;
	clock-prescaler = &amp;lt;0&amp;gt;;
	generator = &amp;lt; &amp;amp;rtc0&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Added the sw_pwm to use the RTC and added the pwm-led information.&lt;/p&gt;
&lt;p&gt;The result on the P0.13 and P0.14 is exactly as I have expected:&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/pastedimage1672693634182v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;but in VS Code I get the flowing &amp;quot;error&amp;quot; during the proj.conf edit:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;CONFIG_PWM_NRF5_SW was assigned the value y, but got the value n. Missing dependencies:&lt;br /&gt;DT_HAS_NORDIC_NRF_SW_PWM_ENABLED&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/pastedimage1672693934388v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I have tried to search the GitHub for some cluses:&amp;nbsp;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/search?q=DT_HAS_NORDIC_NRF_SW_PWM_ENABLED"&gt;https://github.com/zephyrproject-rtos/zephyr/search?q=DT_HAS_NORDIC_NRF_SW_PWM_ENABLED&lt;/a&gt;&amp;nbsp;but I still do not know what I am doing wrong and how to fix the missing dependency on:&amp;nbsp;DT_HAS_NORDIC_NRF_SW_PWM_ENABLED.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/400875?ContentTypeID=1</link><pubDate>Thu, 15 Dec 2022 14:18:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a35aac1-f299-4a26-89d8-2b6bac0f03b3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The RTC is 32.768 kHz and you can get a toggle on every tick, so that should be OK.&lt;/p&gt;
&lt;p&gt;As a side note, this implementation use PPI and GPIOTE also with the RTC, which is different than the low power PWM library in the nRF5 SDK (where only RTC and SW was used via the app_timer library). That frees up the CPU, but which is more power efficient of this and the low_power PWM library in the nRF5 SDK probably depend on the frequency (as PPI usage will increase the idle current, but you will avoid th e high current consumption of the CPU on every change). So for lower frequencies (probably much lower than 4 kHz though I have not measured this), it might be more efficient to do this with kernel timers and setting and clearing GPIOs yourself. If you would like to do that, you could look at the low-power PWM library implementation for inspiration and implement something like that yourself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/400483?ContentTypeID=1</link><pubDate>Tue, 13 Dec 2022 22:10:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4d3a375-1242-49ff-ac89-c765ed6b3796</guid><dc:creator>pmochocki</dc:creator><description>&lt;p&gt;Thank you. I will give it a try. What is the maximum frequency? Will I be able to dive a piezo at 4kHz?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf52840 low power pwm in nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/400202?ContentTypeID=1</link><pubDate>Mon, 12 Dec 2022 15:14:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56277982-1c67-428f-9e6b-0f181d3417c7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is a SW PWM library in the nRF Connect SDK as well, which can be enabled by &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/kconfig/index.html#CONFIG_PWM_NRF5_SW"&gt;CONFIG_PWM_NRF5_SW&lt;/a&gt;. This can be used with a TIMER or RTC for time keeping, and if RTC is used, this would be more or less equivalent with the low power PWM library in the nRF5 SDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>