<?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>n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5227/n-an36-change-the-button-to-pwm</link><description>I would like to modificate the LED Button application example. The LED characteristic should stay as it is, only the Button characteristic should be changed. I want to use the button characteristic to send the value of a pwm signal. When the device is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Feb 2015 08:34:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5227/n-an36-change-the-button-to-pwm" /><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18316?ContentTypeID=1</link><pubDate>Tue, 03 Feb 2015 08:34:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2dbe4ff-1ba1-4520-a7d3-d0eca80ee49f</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;It still doesnt work. I know now, if I remove the app_gpiote.c file from my project, then I have problems with the Connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18318?ContentTypeID=1</link><pubDate>Thu, 29 Jan 2015 14:15:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea2a2961-21e4-4949-8ec1-bdb46aedad5d</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;Hi Stefan&lt;/p&gt;
&lt;p&gt;Since I removed the app_button and app_gpiote files I cannot set the leds. Also the connection is strange: I see my nRF51 DK and can connect with the Chip, but after about 20 seconds it disconnects and then is the Chip not visible anymore.&lt;/p&gt;
&lt;p&gt;Is it possible that the LEDs are related to the Buttons?(in ble_app_lbs example)&lt;/p&gt;
&lt;p&gt;And why do the Chip disconnect after about 20 seconds connection?&lt;/p&gt;
&lt;p&gt;It should work without app_button and app_gpiote file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18317?ContentTypeID=1</link><pubDate>Thu, 29 Jan 2015 11:47:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5f3b602-0d13-413b-903e-1abf002a5304</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Sorry, my bad. Yes, in the ble_app_lbs you use the app_gpiote library which primarily allows many users to use the GPIOTE interrupt. To obtain the button function, the ble_app_lbs uses app_button library which requires app_timers library and app_gpiote. So if you exclude the app_gpiote and app_button functions and includes from your project and comment out the calls to gpiote_init and buttons_init in the main function, then it should compile.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18315?ContentTypeID=1</link><pubDate>Wed, 28 Jan 2015 12:58:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c001923-cd64-42e0-863b-3f450e5c81c5</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;Yes the gpiote_init function seems to be ok. I think the problem is the GPIOTE_IRQHANDLER. Because in the LED Button application example the GPIOTE_IRQHANDLER is in the app_gpiote.c file handled. How I can add the GPIOTE_IRQHANDLER function to the LED Button appliaction example? Can I keep the GPIOTE_IRQHANDLER function in the app_gpiote.c file or do I have to remove it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18310?ContentTypeID=1</link><pubDate>Wed, 28 Jan 2015 09:54:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e0c5ba4-8bb8-4b9a-a52e-e56e8845c10d</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;You need to set the GPIOTE priority explicitly with&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    NRF_GPIOTE-&amp;gt;INTENSET = (GPIOTE_INTENSET_IN1_Enabled &amp;lt;&amp;lt; GPIOTE_INTENSET_IN1_Pos);
sd_nvic_SetPriority(GPIOTE_IRQn, NRF_APP_PRIORITY_LOW);  
sd_nvic_EnableIRQ(GPIOTE_IRQn);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;but otherwise the GPIOTE code should be fine as the GPIOTE peripheral is not blocked by the softdevice, see &lt;a href="https://www.nordicsemi.com/eng/nordic/Products/nRF51822/S110-SDS/20338"&gt;S110 Softdevice Specification v1.3&lt;/a&gt;, table 23&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18311?ContentTypeID=1</link><pubDate>Tue, 27 Jan 2015 12:52:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aec7ebe-a047-4e78-bb42-08286745fe12</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;In the pwm_analyzer project are only 4 functions:timer1_init, GPIOTE_IRQHandler,gpiote_init and ppi_init. The timer1_init and GPIOTE_IRQHandler function I simply copied from the pwm_analyzer project and added it to my project.&lt;/p&gt;
&lt;p&gt;For ppi_init function i did a few changes:&lt;/p&gt;
&lt;p&gt;err_code = sd_ppi_channel_assign(5, &amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[0], &amp;amp;NRF_TIMER1-&amp;gt;TASKS_CAPTURE[0]);&lt;/p&gt;
&lt;p&gt;err_code = sd_ppi_channel_assign(4, &amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[1], &amp;amp;NRF_TIMER1-&amp;gt;TASKS_CAPTURE[1]);&lt;/p&gt;
&lt;p&gt;But what I have to change on the gpiote_init function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18314?ContentTypeID=1</link><pubDate>Mon, 26 Jan 2015 14:03:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08eae7fe-0324-464f-ba85-f3b3c689dd11</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;What are you having problems with exactly? You should be able to use the functionality in the pwm_analyzer example by simply copying the code into the ble_app_lbs example. Instead of writing the PWM value to PORT1 like in the pwm_analyzer exampe, you call the ble_lbs_on_button_change with the pwm value.&lt;/p&gt;
&lt;p&gt;One thing to keep in mind is that the NVIC is blocked by the softdevice so you should use the sd_nvic functions instead when enabling the GPIOTE interrupt. An example of setting a peripheral interrupt when using the softdeivce can be found e.g. &lt;a href="https://github.com/NordicSemiconductor/nrf51-ADC-examples/blob/master/adc-example-with-softdevice/main.c"&gt;here&lt;/a&gt;, in line 825.  Also when you set the ppi channels you must use the the sd_ppi functions, e.g. &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/6.1.0/s110/html/a00937.html#gaa188454bfb10c800a14f21aa29ad84d9"&gt;sd_ppi_channel_enable_set&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18313?ContentTypeID=1</link><pubDate>Mon, 26 Jan 2015 10:55:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a339f19f-944d-4a2e-98dc-d91ab2f996fc</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;There is a pwm_analyzer example in the SDK 6.1 . I tried to add this example in my application, but I have problems port these peripherals over to the nrf_soc API framework.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18312?ContentTypeID=1</link><pubDate>Mon, 26 Jan 2015 10:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b5247ff-7f31-4e09-99ec-ef5382a705f5</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Yes, you should be able to send PWM value or any other 1 byte value over BLE with the method I mention above.&lt;/p&gt;
&lt;p&gt;I guess you could sample the PWM with the ADC on every timer interrupt and then send the sampled value over the BLE link. Or did you have something else in mind?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18319?ContentTypeID=1</link><pubDate>Fri, 23 Jan 2015 14:11:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98115ceb-141a-436d-ba9a-6f752b7c1708</guid><dc:creator>Inspectron</dc:creator><description>&lt;p&gt;The thing is, I dont want to generate a pwm signal. I would like to analyze an external pwm signal and send the value of the PWM over BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: n-AN36 change the Button to PWM</title><link>https://devzone.nordicsemi.com/thread/18309?ContentTypeID=1</link><pubDate>Fri, 23 Jan 2015 13:34:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25cb6dfe-6f49-4b7a-bc59-812ff7195d7c</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;I guess a timer function is what you are asking for. A timer will generate interrupts periodically to send PWM value periodically. The easiest way to implement a timer is to use the &lt;a href="http://developer.nordicsemi.com/nRF51_SDK/doc/7.2.0/s110/html/a00015.html"&gt;app_timer&lt;/a&gt; library which is very low current. You can see an example of app_timer usage in e.g. the ble_app_bps example in the nRF51 SDK v6.1, look at the timers_init() and applicaiton_timers_start() functions in main. For more accurate timer, use a TIMER peripheral, but that consumes substantially more current.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The button_event_handler in the main file in ble_app_lbs is called whenever the button is pressed. You can do the same as the button press does when sending the PWM value, i.e. put the code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    err_code = ble_lbs_on_button_change(&amp;amp;m_lbs, button_action);
    if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
        err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
        err_code != NRF_ERROR_INVALID_STATE)
    {
        APP_ERROR_CHECK(err_code);
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;into a timer handler instead of the button handler. The ble_lbs_on_button_change function accepts uint8_t value so you can send values 0-255 to this function, so that should great with PWM value range of 0-100.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 5.2.2015&lt;/strong&gt;
I attach a modified ble_app_lbs example that measures the PWM duty cycle on input pin P0.00 and sends the value over BLE.  I basically included into the ble_app_lbs the code from the &lt;a href="https://devzone.nordicsemi.com/documentation/nrf51/6.1.0/s110/html/a00038.html"&gt;pwm_analyzer example&lt;/a&gt; in &lt;a href="https://www.nordicsemi.com/eng/nordic/Products/nRF51822/nRF51-SDK-zip/23446"&gt;nRF51 SDK 6.1.0&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf51_2D00_ble_2D00_app_2D00_lbs_2D00_SDK6.0_5F00_with_5F00_pwm_5F00_analyzer.zip"&gt;nrf51-ble-app-lbs-SDK6.0_with_pwm_analyzer.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update 2 5.2.2015&lt;/strong&gt;
To test the example, just create a PWM signal on pin P0.00, I did that with a signal generator. Pressing button does not generate a PWM signal like it did in the pwm_analyzer example. Then connect with a central device and enable services, then you should see the measurements appearing on the central device, i.e. on the button characteristic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>