<?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>PWM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46696/pwm</link><description>Dear nordic, 
 I need a help to create a PWM. I want to create pwm of 10 ms time period and pulse width of 1 micro second. i created PWM of 10 ms time period but how i create pulse width to 1 micro second. I think it has option to change duty cycle of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Apr 2019 07:08:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46696/pwm" /><item><title>RE: PWM</title><link>https://devzone.nordicsemi.com/thread/184440?ContentTypeID=1</link><pubDate>Tue, 30 Apr 2019 07:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5cc9be2-596c-48a1-9fb4-8187a53f31eb</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The period is set by changing the frequency while the pulse width is set by adjusting the duty cyle. Here is an example from the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_pwm.html&amp;amp;cp=5_0_3_34"&gt;documentation &lt;/a&gt;of the PWM library that shows how to setup a PWM signal:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;APP_PWM_INSTANCE(PWM1,1);                   // Create the instance &amp;quot;PWM1&amp;quot; using TIMER1.
void pwm_ready_callback(uint32_t pwm_id)    // PWM callback function
{
    
}
/*
    ...
 */
ret_code_t err_code;
/* 2-channel PWM, 200 Hz, output on DK LED pins. */
app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(5000L, BSP_LED_0, BSP_LED_1);
/* Switch the polarity of the second channel. */
pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH;
/* Initialize and enable PWM. */
err_code = app_pwm_init(&amp;amp;PWM1,&amp;amp;pwm1_cfg,pwm_ready_callback);
APP_ERROR_CHECK(err_code);
app_pwm_enable(&amp;amp;PWM1);
uint32_t value;
while(true)
{
    for (uint8_t i = 0; i &amp;lt; 40; ++i)
    {
        value = (i &amp;lt; 20) ? (i * 5) : (100 - (i - 20) * 5);
        
        /* Se the duty cycle - keep trying until PWM is ready. */
        while (app_pwm_channel_duty_set(&amp;amp;PWM1, 0, value) == NRF_ERROR_BUSY);
        while (app_pwm_channel_duty_set(&amp;amp;PWM1, 1, value) == NRF_ERROR_BUSY);
        nrf_delay_ms(25);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>