<?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>How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/77861/how-to-flash-the-leds-with-a-duty-cycle-that-does-not-equal-50</link><description>Hello, 
 I use the nrf5340 pdk. I would like to flash the led1 with a duty cycle which is different from 50%, so i tried to open the binky_pwm project, but the segger shows that there is error. 
 
 So, I look on the forum and I find that there are people</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Aug 2021 10:04:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/77861/how-to-flash-the-leds-with-a-duty-cycle-that-does-not-equal-50" /><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/324631?ContentTypeID=1</link><pubDate>Thu, 12 Aug 2021 10:04:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68ee3a13-db19-4eb4-b5eb-41f069f407ad</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;I have ported a demo from the nRF5 SDK to NCS v1.4.2, and modified it to the behavior you are looking for.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/4130.blinky_5F00_pwm_5F00_test.zip"&gt;devzone.nordicsemi.com/.../4130.blinky_5F00_pwm_5F00_test.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can probably clean it up a lot, but it seems to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/324157?ContentTypeID=1</link><pubDate>Tue, 10 Aug 2021 08:43:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b91d0de-f7a7-4dcd-8c6c-67cacc8289bb</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;Try using PWM sequences for this. They will let you set up how the PWM should behave over multiple periods, and have different behavior for each channel and for each period, all on a single PWM. You can for example, using a 250ms period, set PWM0, ch0 (LED1) to 4 periods at 100%, followed by 12 periods at 0%, and PWM0, ch1 (LED2) to 4 periods at 0%, 4 periods at 100%, 8 periods at 0% etc.&lt;/p&gt;
&lt;p&gt;I believe the functions in these two files will be useful:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/master/nrfx/drivers/include/nrfx_pwm.h"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/master/nrfx/drivers/include/nrfx_pwm.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-hal_nordic/blob/master/nrfx/drivers/src/nrfx_pwm.c"&gt;https://github.com/nrfconnect/sdk-hal_nordic/blob/master/nrfx/drivers/src/nrfx_pwm.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am looking into the easiest way to access this functionality now, and I will get back to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/323853?ContentTypeID=1</link><pubDate>Fri, 06 Aug 2021 20:17:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b4d3634-730b-4744-893f-626835caf2da</guid><dc:creator>milor</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry to disturb you again.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I want to make the four external leds have the same period and same dutu cycle which equal 25%. It means that these four leds should to be on one after another, the previous one will go out when the next one is on.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I tried to write such code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define PWM_LEDEXT1_NODE	DT_ALIAS(pwm_ledext1)
#define PWM_LEDEXT2_NODE	DT_ALIAS(pwm_ledext2)
#define PWM_LEDEXT3_NODE	DT_ALIAS(pwm_ledext3)
#define PWM_LEDEXT4_NODE	DT_ALIAS(pwm_ledext4)

#if DT_NODE_HAS_STATUS(PWM_LEDEXT1_NODE, okay)
#define PWM_LABELEXT1	DT_PWMS_LABEL(PWM_LEDEXT1_NODE)
#define PWM_CHANNELEXT1	DT_PWMS_CHANNEL(PWM_LEDEXT1_NODE)
#define PWM_FLAGSEXT1	DT_PWMS_FLAGS(PWM_LEDEXT1_NODE)
#else
#error &amp;quot;Unsupported board: pwm-ledext1 devicetree alias is not defined&amp;quot;
#define PWM_LABELEXT1	&amp;quot;&amp;quot;
#define PWM_CHANNELEXT1	0
#define PWM_FLAGSEXT1	0
#endif

#if DT_NODE_HAS_STATUS(PWM_LEDEXT2_NODE, okay)
#define PWM_LABELEXT2	DT_PWMS_LABEL(PWM_LEDEXT2_NODE)
#define PWM_CHANNELEXT2	DT_PWMS_CHANNEL(PWM_LEDEXT2_NODE)
#define PWM_FLAGSEXT2	DT_PWMS_FLAGS(PWM_LEDEXT2_NODE)
#else
#error &amp;quot;Unsupported board: pwm-ledet2 devicetree alias is not defined&amp;quot;
#define PWM_LABELEXT2	&amp;quot;&amp;quot;
#define PWM_CHANNELEXT2	0
#define PWM_FLAGSEXT2	0
#endif

#if DT_NODE_HAS_STATUS(PWM_LEDEXT3_NODE, okay)
#define PWM_LABELEXT3	DT_PWMS_LABEL(PWM_LEDEXT3_NODE)
#define PWM_CHANNELEXT3	DT_PWMS_CHANNEL(PWM_LEDEXT3_NODE)
#define PWM_FLAGSEXT3	DT_PWMS_FLAGS(PWM_LEDEXT3_NODE)
#else
#error &amp;quot;Unsupported board: pwm-ledext3 devicetree alias is not defined&amp;quot;
#define PWM_LABELEXT3	&amp;quot;&amp;quot;
#define PWM_CHANNELEXT3	0
#define PWM_FLAGSEXT3	0
#endif

#if DT_NODE_HAS_STATUS(PWM_LEDEXT4_NODE, okay)
#define PWM_LABELEXT4	DT_PWMS_LABEL(PWM_LEDEXT4_NODE)
#define PWM_CHANNELEXT4	DT_PWMS_CHANNEL(PWM_LEDEXT4_NODE)
#define PWM_FLAGSEXT4	DT_PWMS_FLAGS(PWM_LEDEXT4_NODE)
#else
#error &amp;quot;Unsupported board: pwm-ledext4 devicetree alias is not defined&amp;quot;
#define PWM_LABELEXT4	&amp;quot;&amp;quot;
#define PWM_CHANNELEXT4	0
#define PWM_FLAGSEXT4	0
#endif


#define PERIOD_USEC	(USEC_PER_SEC/5U)
#define PULSE_WIDTH	(PERIOD_USEC/4U)


enum { LEDEXT1, LEDEXT2, LEDEXT3, LEDEXT4 };

void main(void)
{
	const struct device *pwm_dev[4];
        int ret1, ret2, ret3, ret4;

	printk(&amp;quot;PWM-based blinky\n&amp;quot;);

        pwm_dev[LEDEXT1] = device_get_binding(PWM_LABELEXT1);
        pwm_dev[LEDEXT2] = device_get_binding(PWM_LABELEXT2);
        pwm_dev[LEDEXT3] = device_get_binding(PWM_LABELEXT3);
        pwm_dev[LEDEXT4] = device_get_binding(PWM_LABELEXT4);


        if (!pwm_dev[LEDEXT1] || !pwm_dev[LEDEXT2] || !pwm_dev[LEDEXT3] || !pwm_dev[LEDEXT4] ) {
                printk(&amp;quot;Error: cannot find one or more PWM devices\n&amp;quot;);
		return;
	}
        
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;, PWM_LABELEXT1, PWM_CHANNELEXT1);
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;, PWM_LABELEXT2, PWM_CHANNELEXT2);
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;, PWM_LABELEXT3, PWM_CHANNELEXT3);
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;, PWM_LABELEXT4, PWM_CHANNELEXT4);


	while (1) {
                ret1 = pwm_pin_set_usec(pwm_dev[LEDEXT1], PWM_CHANNELEXT1, PERIOD_USEC, PULSE_WIDTH, PWM_FLAGSEXT1);
                if (ret1 != 0) {
                        printk(&amp;quot;Error %d: led externe 1 write failed\n&amp;quot;, ret1);
                        return;
                }

                k_sleep(K_MSEC(50));

                ret1 = pwm_pin_set_usec(pwm_dev[LEDEXT1], PWM_CHANNELEXT1, PERIOD_USEC, 0, PWM_FLAGSEXT1);
                if (ret1 != 0) {
                        printk(&amp;quot;Error %d: led externe 1 write failed\n&amp;quot;, ret1);
                        return;
                }

                        
                ret2 = pwm_pin_set_usec(pwm_dev[LEDEXT2], PWM_CHANNELEXT2, PERIOD_USEC, PULSE_WIDTH, PWM_FLAGSEXT2);
                if (ret2 != 0) {
                        printk(&amp;quot;Error %d: led externe 2 write failed\n&amp;quot;, ret2);
                        return;
                }

                k_sleep(K_MSEC(50));

                ret2 = pwm_pin_set_usec(pwm_dev[LEDEXT2], PWM_CHANNELEXT2, PERIOD_USEC, 0, PWM_FLAGSEXT2);
                if (ret2 != 0) {
                        printk(&amp;quot;Error %d: led externe 2 write failed\n&amp;quot;, ret2);
                        return;
                }

                                
                ret3 = pwm_pin_set_usec(pwm_dev[LEDEXT3], PWM_CHANNELEXT3, PERIOD_USEC, PULSE_WIDTH, PWM_FLAGSEXT3);
                if (ret3 != 0) {
                        printk(&amp;quot;Error %d: led externe 3 write failed\n&amp;quot;, ret3);
                        return;
                }

                k_sleep(K_MSEC(50));

                ret3 = pwm_pin_set_usec(pwm_dev[LEDEXT3], PWM_CHANNELEXT3, PERIOD_USEC, 0, PWM_FLAGSEXT3);
                if (ret3 != 0) {
                        printk(&amp;quot;Error %d: led externe 3 write failed\n&amp;quot;, ret3);
                        return;
                }

                                        
                ret4 = pwm_pin_set_usec(pwm_dev[LEDEXT4], PWM_CHANNELEXT4, PERIOD_USEC, PULSE_WIDTH, PWM_FLAGSEXT4);
                if (ret4 != 0) {
                        printk(&amp;quot;Error %d: led externe 4 write failed\n&amp;quot;, ret4);
                        return;
                }

                k_sleep(K_MSEC(50));

                ret4 = pwm_pin_set_usec(pwm_dev[LEDEXT4], PWM_CHANNELEXT4, PERIOD_USEC, 0, PWM_FLAGSEXT4);
                if (ret4 != 0) {
                        printk(&amp;quot;Error %d: led externe 4 write failed\n&amp;quot;, ret4);
                        return;
                }
        }
 }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But I didn&amp;rsquo;t get the result I wanted. The picture below&amp;nbsp; show the result that I obtened.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1628280922409v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;But what I want is the following picture:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1628280952129v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Do you have any idea?&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;thank you in advanced!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/322787?ContentTypeID=1</link><pubDate>Mon, 02 Aug 2021 07:24:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3b9863b-4676-437c-bfa6-d4f5b743f328</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi again,&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t change the period when you are using two channels on the same PWM like that:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* If any other channel (other than the one being configured) is set up
 * with a non-zero pulse cycle, the period that is currently set cannot
 * be changed, as this would influence the output for this channel.
 */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Set the pulse to 0 before setting the new period:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	period = max_period;

	uint32_t period_temp = max_period;

	while (1) {

                ret = pwm_pin_set_usec(pwm, PWM_CHANNEL,
				       period, period / 2U, PWM_FLAGS);

                retext1 = pwm_pin_set_usec(pwmext1, PWM_CHANNELEXT1,
				       period, period*9U/10U, PWM_FLAGSEXT1);
                
                if (ret) {
			printk(&amp;quot;Error %d: failed to set pulse width for led 0\n&amp;quot;, ret);
			return;
		}
                if (retext1) {
			printk(&amp;quot;Error %d: failed to set pulse width for led 1\n&amp;quot;, retext1);
			return;
		}

		period_temp = period;

		period = dir ? (period * 2U) : (period / 2U);
		if (period &amp;gt; max_period) {
			period = max_period / 2U;
			dir = 0U;
		} else if (period &amp;lt; MIN_PERIOD_USEC) {
			period = MIN_PERIOD_USEC * 2U;
			dir = 1U;
		}

		k_sleep(K_SECONDS(4U));

		ret = pwm_pin_set_usec(pwm, PWM_CHANNEL,
				       period_temp, 0, PWM_FLAGS);

        retext1 = pwm_pin_set_usec(pwmext1, PWM_CHANNELEXT1,
				       period_temp, 0, PWM_FLAGSEXT1);
                
        if (ret) {
			printk(&amp;quot;Error %d: failed to set pulse width to 0 for led 0\n&amp;quot;, ret);
			return;
		}
        if (retext1) {
			printk(&amp;quot;Error %d: failed to set pulse width to 0 for led 1\n&amp;quot;, retext1);
			return;
		}

	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or use a second PWM:&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;pwm0 28&amp;gt;;
		};
		pwm_ledext1: pwm_led_ext1 {
			pwms = &amp;lt;&amp;amp;pwm1 32&amp;gt;;
		};
	};

	aliases {
		pwm-led0 = &amp;amp;pwm_led0;
		pwm-ledext1 = &amp;amp;pwm_ledext1;
	};
};

&amp;amp;pwm0 {
	ch0-pin = &amp;lt;28&amp;gt;;
};

&amp;amp;pwm1 {
	status = &amp;quot;okay&amp;quot;;
	ch0-pin = &amp;lt;32&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/322755?ContentTypeID=1</link><pubDate>Sun, 01 Aug 2021 09:29:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad1e9bed-31c3-4616-974a-4f83b0a8dba1</guid><dc:creator>milor</dc:creator><description>&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;Sorry to bother you again.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;I want to connect led1 and external led with PWM0 to run same frequency.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;In this regard, I set the ch0-pin to 28 followed by led1, then I set the ch1-pin to 32 for the external led.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pwm0 {
          ch0-pin = &amp;lt;28&amp;gt;;
          ch1-pin = &amp;lt;32&amp;gt;;
          };
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;Then in main.c for example blinky-pwm, I write the same code as led1 for external led.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/pwm.h&amp;gt;

#define PWM_LED0_NODE	DT_ALIAS(pwm_led0)
#define PWM_LEDEXT1_NODE	DT_ALIAS(pwm_ledext1)


#if DT_NODE_HAS_STATUS(PWM_LED0_NODE, okay)
#define PWM_LABEL	DT_PWMS_LABEL(PWM_LED0_NODE)
#define PWM_CHANNEL	DT_PWMS_CHANNEL(PWM_LED0_NODE)
#define PWM_FLAGS	DT_PWMS_FLAGS(PWM_LED0_NODE)
#else
#error &amp;quot;Unsupported board: pwm-led0 devicetree alias is not defined&amp;quot;
#define PWM_LABEL	&amp;quot;&amp;quot;
#define PWM_CHANNEL	0
#define PWM_FLAGS	0
#endif


#if DT_NODE_HAS_STATUS(PWM_LEDEXT1_NODE, okay)
#define PWM_LABELEXT1	DT_PWMS_LABEL(PWM_LEDEXT1_NODE)
#define PWM_CHANNELEXT1	DT_PWMS_CHANNEL(PWM_LEDEXT1_NODE)
#define PWM_FLAGSEXT1	DT_PWMS_FLAGS(PWM_LEDEXT1_NODE)
#else
#error &amp;quot;Unsupported board: pwm-ledext1 devicetree alias is not defined&amp;quot;
#define PWM_LABELEXT1	&amp;quot;&amp;quot;
#define PWM_CHANNELEXT1	0
#define PWM_FLAGSEXT1	0
#endif


#define MIN_PERIOD_USEC	(USEC_PER_SEC / 64U)
#define MAX_PERIOD_USEC	USEC_PER_SEC

void main(void)
{
	const struct device *pwm,*pwmext1;
	uint32_t max_period;
	uint32_t period;
	uint8_t dir = 0U;
	int ret,retext1;

	printk(&amp;quot;PWM-based blinky\n&amp;quot;);

        pwm = device_get_binding(PWM_LABEL);
        pwmext1 = device_get_binding(PWM_LABELEXT1);

        if (!pwm) {
		printk(&amp;quot;Error: didn&amp;#39;t find %s device\n&amp;quot;, PWM_LABEL);
		return;
	}
        if (!pwmext1) {
		printk(&amp;quot;Error: didn&amp;#39;t find %s device\n&amp;quot;, PWM_LABELEXT1);
		return;
	}
        
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;,
	       PWM_LABEL, PWM_CHANNEL);
        printk(&amp;quot;Calibrating for device %s channel %d...\n&amp;quot;,
	       PWM_LABELEXT1, PWM_CHANNELEXT1);

	max_period = MAX_PERIOD_USEC;

	while (pwm_pin_set_usec(pwm, PWM_CHANNELE,
				max_period, max_period / 2U, PWM_FLAGS)&amp;amp;&amp;amp;
            pwm_pin_set_usec(pwmext1, PWM_CHANNELEXT1,
				max_period, max_period / 2U, PWM_FLAGSEXT1)) {
		max_period /= 2U;
		if (max_period &amp;lt; (4U * MIN_PERIOD_USEC)) {
			printk(&amp;quot;Error: PWM device %s &amp;quot;
			       &amp;quot;does not support a period at least %u\n&amp;quot;,
			       PWM_LABELEXT1, 4U * MIN_PERIOD_USEC);
			return;
		}
	}

	printk(&amp;quot;Done calibrating; maximum/minimum periods %u/%u usec\n&amp;quot;,
	       max_period, MIN_PERIOD_USEC);

	period = max_period;

	while (1) {

                ret = pwm_pin_set_usec(pwm, PWM_CHANNEL,
				       period, period / 2U, PWM_FLAGS);

                retext1 = pwm_pin_set_usec(pwmext1, PWM_CHANNELEXT1,
				       period, period*9U/10U, PWM_FLAGSEXT1);
                
                if (ret) {
			printk(&amp;quot;Error %d: failed to set pulse width\n&amp;quot;, ret);
			return;
		}
                if (retext1) {
			printk(&amp;quot;Error %d: failed to set pulse width\n&amp;quot;, retext1);
			return;
		}

		period = dir ? (period * 2U) : (period / 2U);
		if (period &amp;gt; max_period) {
			period = max_period / 2U;
			dir = 0U;
		} else if (period &amp;lt; MIN_PERIOD_USEC) {
			period = MIN_PERIOD_USEC * 2U;
			dir = 1U;
		}

		k_sleep(K_SECONDS(4U));
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;But when I run it, the LED does not change the frequency. Then I saw Termite, here showing Error-22: Failed to Set Pulse Width.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;Do you know how to solve it?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;&lt;span style="vertical-align:inherit;"&gt;Thanks in advance!&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/322028?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 11:45:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8edd0589-785f-4319-97e7-934290a9293d</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;You can try something along the lines of:&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;pwm0 32&amp;gt;;
		};
	};

	aliases {
		pwm-led0 = &amp;amp;pwm_led0;
	};
};

&amp;amp;pwm0 {
	ch0-pin = &amp;lt;32&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;pin 32 is P1.00.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/322009?ContentTypeID=1</link><pubDate>Tue, 27 Jul 2021 10:16:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff20ea28-c332-4743-b9dd-386e059e5ce5</guid><dc:creator>milor</dc:creator><description>&lt;p&gt;Hello, thank you for the example.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In fact, I successfully ran the example binky_pwm, so I would like to ask if you know how to set a pwm_ledext1 at pin1.00 because I set an external led at PIN1.00 through the file nrf5340pdk_nrf5340_cpuapp.overlay.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; {
	aliases {
		pwm-led0 = &amp;amp;pwm_led0;
                pwm-ledext1 = &amp;amp;pwm_ledext1;
                ledext1 = &amp;amp;ledext1;
	};
};

/ {
pwmleds {
	compatible = &amp;quot;pwm-leds&amp;quot;;
	pwm_led0: pwm_led_0 {
		pwms = &amp;lt; &amp;amp;pwm0 0x1c &amp;gt;;
	};
        pwm_ledext1: pwm_led_ext1 {
		pwms = &amp;lt; &amp;amp;pwm0 0x1c &amp;gt;;
	};
};
};

/ {
leds {
      compatible = &amp;quot;gpio-leds&amp;quot;;
      ledext1: led_ext1 {
		gpios = &amp;lt;&amp;amp;gpio1 00 GPIO_ACTIVE_LOW&amp;gt;;
		label = &amp;quot;LED EXTERNE 1&amp;quot;;
      };
};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thank you in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to flash the leds with a duty cycle that does not equal 50%?</title><link>https://devzone.nordicsemi.com/thread/321815?ContentTypeID=1</link><pubDate>Mon, 26 Jul 2021 12:31:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6d4527a-61e8-4f73-a60e-f8abf2ce22cb</guid><dc:creator>&amp;#216;ivind</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you want a simpler example, which works out of the box, try the blinky example.&lt;/p&gt;
&lt;p&gt;There you can make a few simple changes to achieve what you are looking for.&lt;/p&gt;
&lt;p&gt;At the top make two different times:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* 1000 msec = 1 sec */
#define ON_TIME_MS      2000
#define OFF_TIME_MS     1000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In the while loop, alternate between the times:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	while (1) {
		gpio_pin_set(dev, PIN, (int)led_is_on);
		led_is_on = false;
		k_msleep(ON_TIME_MS);
		gpio_pin_set(dev, PIN, (int)led_is_on);
		led_is_on = true;
		k_msleep(OFF_TIME_MS);
	}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>