<?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>Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/90753/compiler-error-regarding-pwm-configuration</link><description>Hi all, 
 I&amp;#39;m trying to use the nrf Connect SDK and configure PWM to use in one pin from nordif nrf52DK. The final chip will be the nrf52810. I have configured the builder to use the nrf52dk_nrf52810. I was using the &amp;quot;blinky&amp;quot; example and trying to add</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Aug 2022 15:26:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/90753/compiler-error-regarding-pwm-configuration" /><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/382955?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 15:26:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b4af013-f913-4f26-b810-abe0d59259cd</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;That is good to hear.&lt;/p&gt;
&lt;p&gt;Regarding&amp;nbsp;system off, the&amp;nbsp;method demonstrated by &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/samples/boards/nrf/system_off/README.html"&gt;the nRF5x System Off demo&lt;/a&gt; is valid for any nRF5x device (and it does build for nrf52dk_nrf52810). Please&amp;nbsp;make a new question if you need more assistance on this though, as it is best to keep separate topics in separate threads.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/382857?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 09:09:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bcd20d1-4fde-4e22-b6bc-3a5273552232</guid><dc:creator>clake</dc:creator><description>&lt;p&gt;Hi Einar, thanks for the reply.&lt;/p&gt;
&lt;p&gt;So the error was a wrong configuration inside the prj.conf and for that I have the error in the PWM. Now I can use it and the final prj.conf was:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_GPIO=y

CONFIG_NRFX_PWM0=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Before I have the value CONFIG_PWM_NRFX=y and with that I have to add the sw_pwm to build.&lt;/p&gt;
&lt;p&gt;I have another question but is different, how can I set the nrf52810 to be in deep sleep or power off? there is an example for that? I saw this &lt;a id="" href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nfc/system_off/README.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/samples/nfc/system_off/README.html&lt;/a&gt; but I can&amp;#39;t compile for the nrf52810.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/382806?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2022 06:22:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1f43485-d9a8-4fec-9378-3c04a2a1d2b1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="clake"]If I use the .overlay file that you sent now it builds, but when I want to use the PWM I can&amp;#39;t initiate it (when the binary is flashed in the board, it gives an error)[/quote]
&lt;p&gt;Which error do you get?&lt;/p&gt;
[quote user="clake"]It&amp;#39;s ok to use this code in order to use PWM? For me is more clear to use it this way, but there is another option?[/quote]
&lt;p&gt;Here you are using nrfx, so you are effectively bypassing the Zephyr PWM API.&amp;nbsp;That is OK, but the required config is a bit different.&amp;nbsp;You&amp;nbsp;may find the unofficial &lt;a href="https://github.com/too1/ncs-nrfx-pwm-simple-example"&gt;NRFX PWM Simple Example&lt;/a&gt;&amp;nbsp;useful for that (it is not entirely up to date, but shows the main principles).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/382581?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 08:03:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78d43d4e-c886-47de-9aab-c6815b200f37</guid><dc:creator>clake</dc:creator><description>&lt;p&gt;Hi Einar, sorry for the delay in my response.&lt;/p&gt;
&lt;p&gt;If I use the .overlay file that you sent now it builds, but when I want to use the PWM I can&amp;#39;t initiate it (when the binary is flashed in the board, it gives an error)&lt;/p&gt;
&lt;p&gt;Also I have another question. I&amp;#39;m using the following code to use the PWM:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int pwm_init(void)
{
	static nrfx_pwm_config_t const config0 =
    {
        .output_pins =
        {
            22,						// channel 0
            23,						// channel 1
            NRFX_PWM_PIN_NOT_USED,	// channel 2
            NRFX_PWM_PIN_NOT_USED	// channel 3
        },
        .irq_priority = 5,
        .base_clock   = NRF_PWM_CLK_500kHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = PWM_COUNTERTOP,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    return (nrfx_pwm_init(&amp;amp;my_pwm, &amp;amp;config0, NULL, NULL) == NRFX_SUCCESS) ? 0 : -1;

}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s ok to use this code in order to use PWM? For me is more clear to use it this way, but there is another option?&lt;/p&gt;
&lt;p&gt;Also, I want to add a long press button function but I can&amp;#39;t find a good example to use it.&lt;/p&gt;
&lt;p&gt;Hope you can help me.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/380833?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 12:21:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e35027af-4333-4cb0-9a60-bcf11fd2637f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;No, you do not need to add &amp;quot;sw_pwm&amp;quot;. The nRF52810 also has PWM HW. I just tested again now, and the sample&amp;nbsp;zephyr/samples/basic/blinky_pwm/ works out of the box with this overlay file: &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7532.nrf52dk_5F00_nrf52810.overlay"&gt;devzone.nordicsemi.com/.../7532.nrf52dk_5F00_nrf52810.overlay&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Does it still not work? If now, where did you add the overlay file, and what error do you get when you try to build?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/380829?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 12:03:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1839156e-e7e3-4bda-8fea-0232168ae736</guid><dc:creator>clake</dc:creator><description>&lt;p&gt;Hi Einar and thanks again for your reply.&lt;/p&gt;
&lt;p&gt;Regarding the nrf52dk_nrf52810.overlay, I have to add the line &amp;quot;sw_pwm&amp;quot; in order to use the PWM? because using that example, without that the compiler give me another error before start the compiling process.&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/380826?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2022 11:57:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98a08763-8443-4720-9369-a360588d753d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can use the nrfx driver directly instead of the Zephyr PWM API, yes. I am not sure you can say it is better or worse, that probably depend on the use case. But it is different, and gives you better access to all the HW features. For just simple PWM use cases both would do, and the Zephyr API would be more portable (if that is relevant).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/380638?ContentTypeID=1</link><pubDate>Mon, 08 Aug 2022 13:55:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e07be41c-1055-4db7-8e3e-a9bc20a2efee</guid><dc:creator>clake</dc:creator><description>&lt;p&gt;Hi Eianar,&lt;/p&gt;
&lt;p&gt;Thanks for your reply. I&amp;#39;ll try your suggestion. In the meanwhile I take a look at this comment: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/88796/the-simplest-use-of-pwm-driver"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/88796/the-simplest-use-of-pwm-driver&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This can be a better solution to use PWM? because I can see all the configuration in the main.c file.&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiler error regarding PWM configuration</title><link>https://devzone.nordicsemi.com/thread/380634?ContentTypeID=1</link><pubDate>Mon, 08 Aug 2022 13:39:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd1d3f62-3ab4-4e7b-b8cf-259dc660021c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The devicetree files in nRF Connect SDK 2.0.0 does not contain PWM configuration for &lt;code&gt;nrf52dk_nrf52810&lt;/code&gt;, so that needs to be added, for instance in form of an overlay. However, the overlay file you provided does not seem correct.&lt;/p&gt;
&lt;p&gt;I suggest you test with the PWM sample (zephyr\samples\basic\blinky_pwm\), but modify the overlay file for the board (zephyr\samples\basic\blinky_pwm\boards\nrf52dk_nrf52810.overlay) so that it looks like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;pinctrl {
	pwm0_default: pwm0_default {
		group1 {
			psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 17)&amp;gt;;
			nordic,invert;
		};
	};

	pwm0_sleep: pwm0_sleep {
		group1 {
			psels = &amp;lt;NRF_PSEL(PWM_OUT0, 0, 17)&amp;gt;;
			low-power-enable;
		};
	};
};

/ {
	pwmleds {
		compatible = &amp;quot;pwm-leds&amp;quot;;
		pwm_led0: pwm_led_0 {
			pwms = &amp;lt;&amp;amp;pwm0 0 PWM_MSEC(20) PWM_POLARITY_INVERTED&amp;gt;;
		};
	};

    aliases {
        pwm-led0 = &amp;amp;pwm_led0;
    };
};

&amp;amp;pwm0 {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;pwm0_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;pwm0_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With that the sample should build and run correctly&amp;nbsp;&lt;code&gt;nrf52dk_nrf52810&lt;/code&gt;, and you can use this as a reference for other changes that might be needed for other configurations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>