<?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>callback isn&amp;#39;t optional in app_pwm_init</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7614/callback-isn-t-optional-in-app_pwm_init</link><description>Hi, 
 I bumped into a problem trying to get PWM working and traced it back to the app_pwm_init function, for a simple test case use the the pwm example in the 8.1.0 SDK and change: 
 
 err_code = app_pwm_init(&amp;amp;PWM1,&amp;amp;pwm1_cfg,pwm_ready_callback); </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sun, 14 Jun 2015 11:59:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7614/callback-isn-t-optional-in-app_pwm_init" /><item><title>RE: callback isn't optional in app_pwm_init</title><link>https://devzone.nordicsemi.com/thread/27155?ContentTypeID=1</link><pubDate>Sun, 14 Jun 2015 11:59:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df9bc77a-c70a-4eb4-bf80-8b1bc4e05c67</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Nothing at all to do with r2 and r3 silicon - all you have to do is look at the code for app_pwm_init and see the code says&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t app_pwm_init(app_pwm_t const * const p_instance, app_pwm_config_t const * const p_config,
                        app_pwm_callback_t p_ready_callback)
{
    ASSERT(p_instance);
    ASSERT(p_ready_callback);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So yes that&amp;#39;s going to assert right away if p_ready_callback is NULL.&lt;/p&gt;
&lt;p&gt;If you also check the two places in the code the callback is used, neither of them check for nil eg,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (ticks == p_ch_cb-&amp;gt;pulsewidth)
    {
        p_cb-&amp;gt;p_ready_callback(p_instance-&amp;gt;p_timer-&amp;gt;instance_id);
        return NRF_SUCCESS;     // No action required.
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so NULL Is not an option. Clearly the header file is just wrong in this instance. You can remove the assert() and add a guard to the two places the callback is called only to call if not NULL, or just supply a simple do-nothing handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>