<?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>Turn PWM off and back on</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/20305/turn-pwm-off-and-back-on</link><description>I am using Nordic SDK to develop an application. I need to turn PWM off and turn it back on (to produce a beeping sound from a buzzer). To do this I went into the bsp.c file and added the following code: 
` 
static uint32_t bsp_led_indication(bsp_indication_t</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Mar 2017 18:01:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/20305/turn-pwm-off-and-back-on" /><item><title>RE: Turn PWM off and back on</title><link>https://devzone.nordicsemi.com/thread/79107?ContentTypeID=1</link><pubDate>Wed, 08 Mar 2017 18:01:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59cd7c5d-5531-4163-bc52-a03a53fe2979</guid><dc:creator>Daniel Wang</dc:creator><description>&lt;p&gt;You should not place that functionality in the bsp module. Instead create a buzzer function in main.c, that you call when you get a &lt;code&gt;BLE_GAP_EVT_CONNECTED&lt;/code&gt; in the function on_ble_evt():&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)
{
    uint32_t err_code;

    switch (p_ble_evt-&amp;gt;header.evt_id)
            {
        case BLE_GAP_EVT_CONNECTED:
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);
	    buzzer();
            m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            m_conn_handle = BLE_CONN_HANDLE_INVALID;
            break;

        default:
            // No implementation needed.
            break;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also set the duty cycle to 50 to make a sound, no reason to switch between 0 and 100.
It also looks like you are initializing and enabling the pwm on every beep? If so, your code will run into the error handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>