<?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>new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/53671/new-to-nrf52-and-cant-start-pwm-as-show-in-datasheet-example</link><description>Hello, 
 
 I&amp;#39;ve got a nrf52840 DK and Adafruit nrf52840 Express (less complicated then DK) i&amp;#39;m trying to run a PWM example from datasheet (46 PWM — Pulse width modulation page 556-557). So the code 
 
 im uploading this code with an Arduino IDE and Adafruit</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Nov 2019 08:50:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/53671/new-to-nrf52-and-cant-start-pwm-as-show-in-datasheet-example" /><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/220493?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 08:50:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2083af2-12e6-4a02-811c-bb5a9bd2349f</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;You&amp;#39;re very welcome &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;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/219363?ContentTypeID=1</link><pubDate>Sun, 10 Nov 2019 10:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90734d0e-f86c-4585-a5b6-a78817fea8ed</guid><dc:creator>waksiw</dc:creator><description>&lt;p&gt;Thanks alot for Your help!&lt;/p&gt;
&lt;p&gt;Wasky&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/219002?ContentTypeID=1</link><pubDate>Thu, 07 Nov 2019 09:55:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76fea4ba-6cb7-47b9-91c8-e7ac9ac10bc8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The relationship between the COUNTERTOP (C) value and frequency (f) is f = 16M / C, so it is true that they are not linearly correlated.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you flip the formula you get this: C = 16M / f&lt;/p&gt;
&lt;p&gt;If you change the frequency linearly and update COUNTERTOP according to this formula then the output frequency should change linearly as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Using PWM and BLE at the same time is no issue, just make sure you don&amp;#39;t route any high frequency GPIO signal close to the antenna or the RF network.&amp;nbsp;&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><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/218778?ContentTypeID=1</link><pubDate>Wed, 06 Nov 2019 10:05:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5a71495-d97c-478a-ade9-8dc874d0627f</guid><dc:creator>waksiw</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I did manage to set pins and change PWM frequency and duty cycle &amp;quot;on the fly&amp;quot; but have encountered new problem: Frequency is changing non-linear.&lt;/p&gt;
&lt;p&gt;For example 16MHz clock and COUNTERTOP in between 160(100kHz) and 1600(10kHz)&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/3652.Untitled.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Is there a way to set-up PWM frequency that changes linear with 1kHz step lets say?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;and Yes, I do plan to use bluetooth for my project, is it affected by PWM?&lt;/p&gt;
&lt;p&gt;Wasky.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/218428?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2019 07:57:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7a7d42e-1223-43bf-ab58-cb34e1f76db8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;&lt;span&gt;PWM_CH0_DUTY should set the duty cycle on the &lt;em&gt;first_pin&lt;/em&gt; output, and PWM_CH1_DUTY should set the duty cycle on the &lt;em&gt;second_pin&lt;/em&gt; output.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Since COUNTERTOP is set to 16000 it means you need to set the PWM_CHx_DUTY defines in the 0-16000 range, where the duty cycle in percent would equal (PWM_CHx_DUTY/16000) * 100&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which pins are you using PWM?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you made sure they are not used for anything else?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are you planning to add some wireless functionality to the example?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/217992?ContentTypeID=1</link><pubDate>Fri, 01 Nov 2019 14:42:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a88a5241-2cb3-4aca-9b45-042779fd79ca</guid><dc:creator>waksiw</dc:creator><description>&lt;p style="margin-top:0cm;"&gt;&lt;span style="color:black;font-family:&amp;#39;Arial&amp;#39;,sans-serif;font-size:9.0pt;" lang="EN-US"&gt;Thanks for Your reply, I have figured out with PINs. DK seems to be ok, but SEGGER is a bit more complicated (tbh it&amp;rsquo;s very complicated when you switch from Arduino IDE to SEGGER) and I&amp;nbsp;have problem&amp;nbsp;with adding libraries to SEGGER. Also cant fully understand which of them I need, basically what I&amp;rsquo;m trying to do, is run PWM on 2 pins with ~50% duty cycle (a bit less because need a dead time around 130us) and be able to change frequency in range 10kHz-100kHz, which is controlled by potentiometer. After failing to set up SAADC I got an Ad fruit nrf52 express, because it&amp;rsquo;s possible to use it with Arduino IDE and use simple functions such as analogRead(), but I have also failed to understand how&amp;nbsp;{PWM_CH0_DUTY, PWM_CH1_DUTY, PWM_CH2_DUTY, PWM_CH3_DUTY}; works (sitting with oscilloscope and changing things doesn&amp;rsquo;t gave any result)&lt;/span&gt;&lt;/p&gt;
&lt;p style="text-align:start;"&gt;&lt;span style="color:black;font-family:&amp;#39;Arial&amp;#39;,sans-serif;font-size:9.0pt;" lang="EN-US"&gt;So yeah, I&amp;rsquo;m kind of stuck between nrf52 DK and Adafruit nrf52&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: new to nrf52 and cant start PWM as show in datasheet example</title><link>https://devzone.nordicsemi.com/thread/217113?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 13:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb3a2c69-4c46-4bf4-b594-f0b427b7fc8c</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Doesn&amp;#39;t Arduino provide it&amp;#39;s own PWM API so you don&amp;#39;t have to implement it from scratch?&lt;/p&gt;
&lt;p&gt;In general we don&amp;#39;t support non Nordic kits (one advantage of using the DK), but generic questions we can obviously answer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/em&gt;&lt;em&gt;&lt;strong&gt;PWM_CHx_DUTY is a duty cycle of a PWM and why are there 4 duty cycles?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Each PWM module supports up to 4 output channels. Each of these channels will share frequency and phase, but have individual duty cycle control, and an individual invert setting allowing you to invert the output.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;first_pin (second pin) is just a number of pin? for example, ih LED is connected to P1.15, should i just define first_pin = 15? Because it doesnt seems to work.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Setting the pin to 15 enables P0.15, not P1.15. To use port 1 you have to add 32 to the pin number, so that first_pin should be assigned (32 + 15), or 47&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>