<?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>nRF5340DK PWM mess with zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70875/nrf5340dk-pwm-mess-with-zephyr</link><description>Using NCS v1.4.99-dev1. 
 I have no problem using the PWM with a nRF5340PDK but when i tried it on a nRF5340DK, my program was not working correctly. 
 I have made a simple example to demonstrate this behavior, 1 LED should blink with PWM and another</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Jan 2021 14:30:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70875/nrf5340dk-pwm-mess-with-zephyr" /><item><title>RE: nRF5340DK PWM mess with zephyr</title><link>https://devzone.nordicsemi.com/thread/291822?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 14:30:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a240439-460e-4411-8445-48e0a88660dc</guid><dc:creator>Nicolas Brunner</dc:creator><description>&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;I tested further and saw that a call to nrf_gpio_cfg_output(0) make the 32k fail on the DK but not on the PDK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK PWM mess with zephyr</title><link>https://devzone.nordicsemi.com/thread/291773?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 12:22:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7591651-30e7-4cb0-9d3d-740008fe267c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It seems that the problem is caused by some incorrect fields in your PWM config. You do not set&amp;nbsp;output_pins[1]-[3], which will set these to 0. This again will connect P0.00 to the PWM peripheral, preventing it from being controlled correctly from other peripherals.&lt;/p&gt;
&lt;p&gt;By default, P0.00 is used for the 32.768 kHz LF crystal, which is used by RTC and k_sleep to control the sleep modes.&lt;/p&gt;
&lt;p&gt;I verified that both these options resolves the issue:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set unused pins to&amp;nbsp;NRFX_PWM_PIN_NOT_USED in PWM config:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void pwm_init(void)
{
	nrfx_pwm_config_t config = {
		.irq_priority = PWM_DEFAULT_CONFIG_IRQ_PRIORITY,
		.base_clock   = NRF_PWM_CLK_125kHz,
		.count_mode   = NRF_PWM_MODE_UP,
		.top_value    = PERIOD,
		.load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
		.step_mode    = NRF_PWM_STEP_AUTO,
		.output_pins[0] = LED2_PIN,
		.output_pins[1] = NRFX_PWM_PIN_NOT_USED,
		.output_pins[2] = NRFX_PWM_PIN_NOT_USED,
		.output_pins[3] = NRFX_PWM_PIN_NOT_USED,
    };

    nrfx_err_t err = nrfx_pwm_init(&amp;amp;pwm, &amp;amp;config, NULL, NULL);
    assert(err == NRFX_SUCCESS);

    nrfx_pwm_simple_playback(&amp;amp;pwm, &amp;amp;sequence, 1, NRFX_PWM_FLAG_LOOP);
}&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Configure the 32k clock source to use internal RC oscillator, by adding the following configs to prj.conf:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK PWM mess with zephyr</title><link>https://devzone.nordicsemi.com/thread/291444?ContentTypeID=1</link><pubDate>Wed, 27 Jan 2021 08:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ad5fa8d-ae2b-4546-8523-889de3000100</guid><dc:creator>Nicolas Brunner</dc:creator><description>&lt;p&gt;Yes, i have the same behavior on my DK.&lt;/p&gt;
&lt;p&gt;I have done further testing and if i replace the k_sleep() with &amp;quot;for (volatile uint32_t i = 0; i &amp;lt; 1000000; i++);&amp;quot;, both LED blink.&lt;/p&gt;
&lt;p&gt;So why does PWM make k_sleep() never exist on a nRF5340DK but work correctly on a nRF5340PDK ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340DK PWM mess with zephyr</title><link>https://devzone.nordicsemi.com/thread/291379?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 20:20:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94424dcf-5eb2-4cb5-9393-696b8d3551e9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I tested your code on my DK, and it seems like LED1 starts to blink if I comment our pwm_init(). With pwm_init() included, only LED2 blinks. Can you check if this is also true on your board?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>