<?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 stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7588/how-to-stop-pwm-and-set-pin-to-clear</link><description>Hi,all.i use pwm with sdk8.1 sample (SDK8.1\example\peripheral\pwm),my question is how to stop pwm and set the pin to low level? is my code correct?
my pwm init code: 
 
 static uint32_t init_pwm(uint32_t perior,uint8_t pin)
 { 
 uint32_t err_code</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 29 May 2016 11:41:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7588/how-to-stop-pwm-and-set-pin-to-clear" /><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27078?ContentTypeID=1</link><pubDate>Sun, 29 May 2016 11:41:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:188e4e62-940a-44fb-a607-dba91938425f</guid><dc:creator>Ali</dc:creator><description>&lt;p&gt;I face with this problem too. I&amp;#39;m using SDK11.0 :(
after I start PWM but I can&amp;#39;t stop it. I have try every single top steps but I didn&amp;#39;t get any good result.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27076?ContentTypeID=1</link><pubDate>Wed, 02 Dec 2015 19:32:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98d85d47-2728-447f-8744-c17dc3727914</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;did you try using sdk10?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27077?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2015 08:03:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b73ea91-af28-46ed-ae17-f5a226144498</guid><dc:creator>Milk</dc:creator><description>&lt;p&gt;I also met this situation by SDK9.0,still do not know how to solve this problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27056?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2015 00:42:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28d70702-b344-4235-995a-bebbbe03a2c5</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Using SDK 9, SD110, app_pwm driver, also app_scheduler, I am also trying to find an answer/workaround to the very same problem after trying unsuccessfully the solutions in this thread. So far I can&amp;#39;t disable a pin left high by the PWM, using the app_pwm driver. The typical period I need is 250 us.
I also tried setting duty to 0% first before disabling, but this did not help, hinting at an inversion from the toggle.
I am hoping for a successful workaround before considering rewriting a PWM driver.
Any news Nordic, Mahesh?
Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27073?ContentTypeID=1</link><pubDate>Thu, 13 Aug 2015 01:20:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6a99472-ade4-4d1c-835d-0bab6972d34a</guid><dc:creator>Lucas</dc:creator><description>&lt;p&gt;this library is a piece&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27072?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2015 09:53:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d5d2232f-aeed-40e3-930d-e71d5d4b9981</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;ol start="73"&gt;
&lt;li&gt;TIMER&lt;/li&gt;
&lt;/ol&gt;
&lt;hr /&gt;
&lt;p&gt;Use of an EVENT from any TIMER module to trigger a TASK in GPIOTE or RTC using the PPI could fail under, But this workaround is enabled by default app_pwm. And it can be found &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.pdf.panpcn/nRF51422-pan_v3.0.pdf"&gt;here&lt;/a&gt;
certain conditions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27071?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2015 09:01:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c0f2e5b-cb6e-426e-bbb8-61201655457e</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Sorry,what&amp;#39;s mean &amp;quot;PAN-73&amp;quot;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27070?ContentTypeID=1</link><pubDate>Sun, 09 Aug 2015 03:44:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:313fe9f3-a747-4a57-938d-7f636c5a41b0</guid><dc:creator>Mahesh Venkitachalam</dc:creator><description>&lt;p&gt;I suggest creating a github gist and posting a link.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27069?ContentTypeID=1</link><pubDate>Sun, 09 Aug 2015 03:39:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9cb52093-db29-48bb-86bd-74c6c470971e</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Thanks Aryan! How to upload my code here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27066?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2015 10:27:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4fb69ca-6394-4e9c-b39a-95b853d5517b</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;wuvo, i am not able to reproduce it, can you give me the code and the setup details on which you tried this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27064?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2015 09:25:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e303b41-1d75-4bdd-a134-17a9bac7f465</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I will try it out today and see what we can do&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27068?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2015 01:32:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9537422-b46a-4810-8299-b9c7aadc5a7d</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;my device&amp;#39;s current is about 7uA before call pwm_start(),and call it,current is about 300uA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27075?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2015 01:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99bc2b3a-cedc-46a8-aeb2-1076b810e5f0</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;The device&amp;#39;s current can&amp;#39;t decrease after call pwm_start() even if call pwm_stop().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27067?ContentTypeID=1</link><pubDate>Sun, 02 Aug 2015 11:15:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9d822a2-8918-46da-80dd-60fa61bea3f7</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I did not really understand what you mean by &amp;quot;can&amp;#39;t go back to start pwm before&amp;quot;.
Is this problem related to the fix we described here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27065?ContentTypeID=1</link><pubDate>Sun, 02 Aug 2015 04:03:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b384c644-ef90-41d4-be5a-7bf5c53b0653</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Thanks,Aryan! i found a new problem:after i stop pwm and uninit pwm,my device keep current about 300uA,and can&amp;#39;t go back to start pwm before.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27063?ContentTypeID=1</link><pubDate>Fri, 31 Jul 2015 06:01:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:441bf49c-449e-4a82-81c9-89e6e708f376</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Yes, still unresolved.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27062?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2015 15:42:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d29f2e24-294a-4cf7-8855-25fde6fe7402</guid><dc:creator>Mahesh Venkitachalam</dc:creator><description>&lt;p&gt;Just want to mention that this is still a problem with 9.0.0.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27061?ContentTypeID=1</link><pubDate>Wed, 24 Jun 2015 08:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f88f7227-5f97-4a73-beae-3b3ae36a8253</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Thanks Aryan! i solved this problem as what you said.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27060?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 15:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4d63e49-ee24-4abf-95b0-eefb143ae67c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;That should have worked, If this does not work then it means that somewhere GPIOTE still owns the pin.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_gpiote_out_task_disable(SPEAKER_PIN);
nrf_gpio_cfg_output(SPEAKER_PIN);
nrf_gpio_pin_clear(SPEAKER_PIN);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27074?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 13:27:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65280801-32b7-4bcd-a78e-27644aff784b</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Thanks,Aryan.i tested as what your say,but the pin is high level always.no effects.i want to controll buzzer used pwm.what&amp;#39;s wrong?i reconfig pwm before i start(restart) pwm using code as follow:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;-------------------------------------------------------------------------
uint32_t reconfig_pwm(uint32_t perior,uint8_t pin)
{
	uint32_t err_code = 0;

	err_code = app_pwm_uninit(&amp;amp;PWM1); 	
	APP_ERROR_CHECK(err_code);

	if( err_code == NRF_SUCCESS)
	{
	  err_code =	init_pwm(perior,pin);
		APP_ERROR_CHECK(err_code);
	}
	
	//while (app_pwm_channel_duty_set(&amp;amp;PWM1, 0, 50) == NRF_ERROR_BUSY);

	return err_code;

}

static uint32_t init_pwm(uint32_t perior,uint8_t pin)
 {	 
	 	uint32_t err_code = 0;

		nrf_gpio_pin_dir_set(pin, NRF_GPIO_PIN_DIR_OUTPUT);
		nrf_gpio_pin_clear(pin);
	 
    /* 2-channel PWM, 200Hz, output on DK LED pins. */
	  app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(perior, pin);
	 
	 pwm1_cfg.pin_polarity[0] = APP_PWM_POLARITY_ACTIVE_LOW;
    
    /* Initialize and enable PWM. */
    err_code = app_pwm_init(&amp;amp;PWM1,&amp;amp;pwm1_cfg,pwm_ready_callback);
    APP_ERROR_CHECK(err_code);

    return err_code;
}
------------------------------------------------------------------------------------------------
then,start it:
void pwm_start( void )
{   
   app_pwm_enable(&amp;amp;PWM1);
	 while (app_pwm_channel_duty_set(&amp;amp;PWM1, 0, 50) == NRF_ERROR_BUSY);
}
-----------------------------------------------------------------------------------------------
stop as this:
void pwm_stop( void )
{ 
	  app_pwm_disable(&amp;amp;PWM1);
	  nrf_drv_gpiote_out_task_disable(SPEAKER_PIN);
          nrf_gpio_pin_clear(SPEAKER_PIN);

//	  while (app_pwm_channel_duty_set(&amp;amp;PWM1, 0, 0) == NRF_ERROR_BUSY);
	  pos = 0;
	  time = 0;
	  k = 0;
	  freq = 0;
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27059?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 12:25:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2e1869a-6af3-4cb3-ad4b-5530d2cfa7ae</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;void pwm_start( void )
{&lt;br /&gt;
nrf_drv_gpiote_out_task_enable(pin_number);
app_pwm_enable(&amp;amp;PWM1);
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27058?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 12:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cb6d356-c4a6-4ae4-a2b1-9e47095380b1</guid><dc:creator>wuvo.leo</dc:creator><description>&lt;p&gt;Thanks! And after stop pwm,how to restart it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to stop pwm and set pin to clear</title><link>https://devzone.nordicsemi.com/thread/27057?ContentTypeID=1</link><pubDate>Fri, 12 Jun 2015 07:40:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1714622-bb26-4991-9c37-dd423b3662b3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi wuvo,
I have noticed that app_pwm library does not disable a GPIOTE config, which means that it does not free the pin from gpiote after you are done. I created a ticket for it for the team.&lt;/p&gt;
&lt;p&gt;For your code you can do this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;before initializing pwm library, you configure the pin through gpio interface&lt;/p&gt;
&lt;p&gt;nrf_gpio_pin_dir_set(pin_number, NRF_GPIO_PIN_DIR_OUTPUT);
nrf_gpio_pin_clear(pin_number);&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Then you initialize PWM using app_pwm library, do your stuff&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;in your pwm_stop add three lines to it&lt;/p&gt;
&lt;p&gt;void pwm_stop( void )
{
app_pwm_disable(&amp;amp;PWM1);
nrf_drv_gpiote_out_task_disable(pin_number);
nrf_gpio_cfg_output(pin_number)
nrf_gpio_pin_clear(pin_number);
}&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now as soon as the pin is freed by &lt;code&gt;nrf_drv_gpiote_out_task_disable&lt;/code&gt; then gpio configuration will take into effect.&lt;/p&gt;
&lt;h2&gt;EDIT: 10.08.2015&lt;/h2&gt;
&lt;p&gt;PAN-73 workaround is enabled by default in app_pwm_init&lt;/p&gt;
&lt;p&gt;PAN-73 workaround is disabled in app_pwm_uninit&lt;/p&gt;
&lt;p&gt;This means there will be increase in power consumption (~50uA) if the PAN-72 workaround is enabled.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/47632/app_pwm_init-drives-excessive-current/"&gt;Check here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>