<?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 failed to work with SoftDevice 8.0 in nRF51822</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/7653/pwm-failed-to-work-with-softdevice-8-0-in-nrf51822</link><description>I may be missing something. I am trying to generate a square wave from a GPIO pin in a BLE application (SoftDevice 8.0). I tried libraries (nrf_pwm.c and nrf_pwm.h) in this post and also in this repo . I created two functions as follows: 
 #define V_CLK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jun 2015 07:47:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/7653/pwm-failed-to-work-with-softdevice-8-0-in-nrf51822" /><item><title>RE: PWM failed to work with SoftDevice 8.0 in nRF51822</title><link>https://devzone.nordicsemi.com/thread/27271?ContentTypeID=1</link><pubDate>Thu, 18 Jun 2015 07:47:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71916292-afe1-494b-b855-9312bff08bcf</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The SoftDevice API&amp;#39;s (sd_ppi_... for instance) will only work after the SD is enabled, which is why you have to initialize PWM after the SD when setting USE_SOFTDEVICE = 1 in the PWM library.&lt;/p&gt;
&lt;p&gt;When USE_SOFTDEVICE = 0 the PWM driver will access peripherals such as NRF_PPI directly, and if you try to do this when the SD is enabled you will get a hard fault.
That is why the advice earlier was to initialize the PWM driver before the SD, so that the PPI configuration would work.&lt;/p&gt;
&lt;p&gt;Now that the USE_SOFTDEVICE define is added you should just use this when using PWM with the SD.&lt;/p&gt;
&lt;p&gt;Regards
Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM failed to work with SoftDevice 8.0 in nRF51822</title><link>https://devzone.nordicsemi.com/thread/27270?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2015 17:13:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df5c1232-93d5-485c-acb4-f61668ae0ff6</guid><dc:creator>diode</dc:creator><description>&lt;p&gt;Hi Øyvind, your advice works. I also found that the libraries in &lt;a href="https://devzone.nordicsemi.com/question/798/is-there-an-example-code-for-using-pwm-on-the-nrf51822-with-a-softdevice/"&gt;this post&lt;/a&gt; just don&amp;#39;t work, no matter I call pwm_init() before or after ble_stack_init(). For &lt;a href="https://github.com/NordicSemiconductor/nrf51-pwm-library"&gt;this repo&lt;/a&gt;, it only works if calling pwm_init() after ble_stack_init(). Why is the calling sequence reversed here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM failed to work with SoftDevice 8.0 in nRF51822</title><link>https://devzone.nordicsemi.com/thread/27268?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2015 09:02:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e62bbd94-2895-4c81-9ad3-71d0c3249424</guid><dc:creator>JohnBrown</dc:creator><description>&lt;p&gt;I don&amp;#39;t know why your code is not working, but if you are really only looking to produce a square wave, i.e constant 50% duty cycle(or any other constant duty cycle, which would more accurately be described as a rectangular wave), and at a constant frequency, I would write the thing myself, using a counter timer and GPIOTE.&lt;/p&gt;
&lt;p&gt;If you are hoping to vary either the duty or the frequency on the fly, then good luck with that.&lt;/p&gt;
&lt;p&gt;It is, in my humble opinion, a weakness of the nRF51822, in that the compare registers are not double buffered, and you can not have a SET and a CLEAR task directed to a single I/O pin, but have to rely on a TOGGLE instead. I say this as someone who has fought with this in a quest to reliably produce DTMF tones WITHOUT the SD running!&lt;/p&gt;
&lt;p&gt;However, I suppose the designers have tough choices to make about the best use of silicon...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM failed to work with SoftDevice 8.0 in nRF51822</title><link>https://devzone.nordicsemi.com/thread/27269?ContentTypeID=1</link><pubDate>Wed, 17 Jun 2015 08:50:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2fa016c-ebf7-45b0-bf77-004f8a5d4af8</guid><dc:creator>&amp;#216;yvind Karlsen</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re using the code from &lt;a href="https://github.com/NordicSemiconductor/nrf51-pwm-library"&gt;this repo&lt;/a&gt;, pwm_init() should be called after the soft device has been initialized. Hopefully this solves your problem.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>