<?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>Simple PWM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46740/simple-pwm</link><description>Hello, 
 I am new to Nordic devices. So it is tough for me to understand PWM examples. Can you provide me the simple code of PWM? Basically, I want to give a specific brightness to the led. With specific frequency. I am using nrf dongle (PCA10059) with</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 01 May 2019 15:14:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46740/simple-pwm" /><item><title>RE: Simple PWM</title><link>https://devzone.nordicsemi.com/thread/184709?ContentTypeID=1</link><pubDate>Wed, 01 May 2019 15:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0951b13d-3f72-44b2-909a-87fad6c33074</guid><dc:creator>parman</dc:creator><description>&lt;p&gt;Thank You for your guidance Mr. Awneil. I will follow your steps and reply back.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM</title><link>https://devzone.nordicsemi.com/thread/184683?ContentTypeID=1</link><pubDate>Wed, 01 May 2019 09:14:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24881f14-7b94-428a-b608-28c09fa6eaa9</guid><dc:creator>awneil</dc:creator><description>[quote userid="78795" url="~/f/nordic-q-a/46740/simple-pwm/184671"]nrf_drv_pwm.h: No such file or directory[/quote]
&lt;p&gt;Answered in your ADC thread:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/46716/simple-adc-code/184681#184681"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/46716/simple-adc-code/184681#184681&lt;/a&gt;&lt;/p&gt;
[quote userid="78795" url="~/f/nordic-q-a/46740/simple-pwm/184671"]I am new[/quote]
&lt;p&gt;Here are some &amp;#39;C&amp;#39; learning &amp;amp; reference materials for you:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blog.antronics.co.uk/category/c-programming/"&gt;http://blog.antronics.co.uk/category/c-programming/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also, some microcontroller &amp;quot;getting started&amp;quot; tips:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.avrfreaks.net/comment/2079906#comment-2079906"&gt;https://www.avrfreaks.net/comment/2079906#comment-2079906&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;How to properly post source code:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/8054._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM</title><link>https://devzone.nordicsemi.com/thread/184671?ContentTypeID=1</link><pubDate>Wed, 01 May 2019 07:45:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8883af6c-7653-43c6-a115-71f26c2e7900</guid><dc:creator>parman</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp;Glad to hear from you&lt;/p&gt;
&lt;p&gt;But I am unable to open the page saying the -&lt;/p&gt;
&lt;h2&gt;Access Denied&lt;/h2&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x900/__key/communityserver-discussions-components-files/4/Access_5F00_Denied.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But I found some code -&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;
&lt;p&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;string.h&amp;gt;&lt;br /&gt;#include &amp;quot;nrf_drv_pwm.h&amp;quot;&lt;br /&gt;#include &amp;quot;app_util_platform.h&amp;quot;&lt;br /&gt;#include &amp;quot;app_error.h&amp;quot;&lt;br /&gt;#include &amp;quot;boards.h&amp;quot;&lt;br /&gt;#include &amp;quot;bsp.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_drv_clock.h&amp;quot;&lt;br /&gt;#include &amp;quot;nrf_delay.h&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;#define OUTPUT_PIN LED_1&lt;/p&gt;
&lt;p&gt;static nrf_drv_pwm_t m_pwm0 = NRF_DRV_PWM_INSTANCE(0);&lt;/p&gt;
&lt;p&gt;// Declare variables holding PWM sequence values. In this example only one channel is used &lt;br /&gt;nrf_pwm_values_individual_t seq_values[] = {0, 0, 0, 0};&lt;br /&gt;nrf_pwm_sequence_t const seq =&lt;br /&gt;{&lt;br /&gt; .values.p_individual = seq_values,&lt;br /&gt; .length = NRF_PWM_VALUES_LENGTH(seq_values),&lt;br /&gt; .repeats = 0,&lt;br /&gt; .end_delay = 0&lt;br /&gt;};&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;// Set duty cycle between 0 and 100%&lt;br /&gt;void pwm_update_duty_cycle(uint8_t duty_cycle)&lt;br /&gt;{&lt;br /&gt; &lt;br /&gt; // Check if value is outside of range. If so, set to 100%&lt;br /&gt; if(duty_cycle &amp;gt;= 100)&lt;br /&gt; {&lt;br /&gt; seq_values-&amp;gt;channel_0 = 100;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; seq_values-&amp;gt;channel_0 = duty_cycle;&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt; nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;seq, 1, NRF_DRV_PWM_FLAG_LOOP);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;static void pwm_init(void)&lt;br /&gt;{&lt;br /&gt; nrf_drv_pwm_config_t const config0 =&lt;br /&gt; {&lt;br /&gt; .output_pins =&lt;br /&gt; {&lt;br /&gt; OUTPUT_PIN, // channel 0&lt;br /&gt; NRF_DRV_PWM_PIN_NOT_USED, // channel 1&lt;br /&gt; NRF_DRV_PWM_PIN_NOT_USED, // channel 2&lt;br /&gt; NRF_DRV_PWM_PIN_NOT_USED, // channel 3&lt;br /&gt; },&lt;br /&gt; .irq_priority = APP_IRQ_PRIORITY_LOWEST,&lt;br /&gt; .base_clock = NRF_PWM_CLK_1MHz,&lt;br /&gt; .count_mode = NRF_PWM_MODE_UP,&lt;br /&gt; .top_value = 100,&lt;br /&gt; .load_mode = NRF_PWM_LOAD_INDIVIDUAL,&lt;br /&gt; .step_mode = NRF_PWM_STEP_AUTO&lt;br /&gt; };&lt;br /&gt; // Init PWM without error handler&lt;br /&gt; APP_ERROR_CHECK(nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, NULL));&lt;br /&gt; &lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;/p&gt;
&lt;p&gt;// Start clock for accurate frequencies&lt;br /&gt; NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1; &lt;br /&gt; // Wait for clock to start&lt;br /&gt; while(NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0) &lt;br /&gt; ;&lt;br /&gt; &lt;br /&gt; pwm_init();&lt;/p&gt;
&lt;p&gt;for (;;)&lt;br /&gt; {&lt;br /&gt; for(int i = 0; i &amp;lt;= 100; i++)&lt;br /&gt; {&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt; pwm_update_duty_cycle(i);&lt;br /&gt; }&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////&lt;/p&gt;
&lt;p&gt;But I got some errors -&lt;/p&gt;
&lt;p&gt;Rebuilding &amp;lsquo;blinky_pca10059_mbr&amp;rsquo; from solution &amp;lsquo;blinky_pca10059_mbr&amp;rsquo; in configuration &amp;lsquo;Release&amp;rsquo;&lt;br /&gt; Assembling &amp;lsquo;thumb_crt0.s&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_log_frontend.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_log_str_formatter.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;boards.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;app_error.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;app_error_handler_gcc.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;app_error_weak.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;app_util_platform.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_assert.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_atomic.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_balloc.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_fprintf.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_fprintf_format.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_memobj.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_ringbuf.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrf_strerror.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;nrfx_atomic.c&amp;rsquo;&lt;br /&gt; Compiling &amp;lsquo;main.c&amp;rsquo;&lt;br /&gt; nrf_drv_pwm.h: No such file or directory&lt;br /&gt;Build failed&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But I am new so I am not able to figure out the errors. Sorry. Kindly guide me.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Waiting for your quick response&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM</title><link>https://devzone.nordicsemi.com/thread/184602?ContentTypeID=1</link><pubDate>Tue, 30 Apr 2019 13:29:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59adcc6e-0f4d-437f-b99c-82c62e588706</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Parman&lt;/p&gt;
&lt;p&gt;I shared a simple PWM example a couple of months ago:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/support-private/support/221537"&gt;https://devzone.nordicsemi.com/support-private/support/221537&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please take a look at that &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>