<?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 modulation frequency or modulation amplitude</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40071/pwm-modulation-frequency-or-modulation-amplitude</link><description>Hello, above is the PWM modulation waveform (positive Xuan Bo). 
 How does 1.nrf52832 regulate the frequency of circulation? 
 Take this nRF5_SDK_12.2.0_f012efa\examples\peripheral\pwm_driver example Demo1 as an example. 
 I want to give variable frequency</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Nov 2018 05:54:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40071/pwm-modulation-frequency-or-modulation-amplitude" /><item><title>RE: PWM modulation frequency or modulation amplitude</title><link>https://devzone.nordicsemi.com/thread/156794?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 05:54:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05b5e6ef-c159-4d67-aede-9227b60b2e67</guid><dc:creator>creator</dc:creator><description>&lt;p&gt;Thank you for your reply, you can change the frequency output.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM modulation frequency or modulation amplitude</title><link>https://devzone.nordicsemi.com/thread/156349?ContentTypeID=1</link><pubDate>Wed, 07 Nov 2018 14:56:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c1fb49b-e379-4b8e-9fd8-c119018887d1</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;The driver does not support it, but you could try to set the COUNTERTOP register directly in the handler. The duty cycle will also change if you only increase the top_value, so if you want the duty cycle to be the same, you will need to update the seq_value also. You will also need to add some RC filter, or similar to the pin output to get the desired output shown in the image you uploaded.&lt;/p&gt;
&lt;p&gt;Snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static nrf_pwm_values_individual_t seq_values_new;
static void demo1_handler(nrf_drv_pwm_evt_type_t event_type)
{
    if (event_type == NRF_DRV_PWM_EVT_FINISHED)
    {
        uint32_t current_mtop = NRF_PWM0-&amp;gt;COUNTERTOP;

         if(current_mtop &amp;lt; 32767 )
         {
            NRF_PWM0-&amp;gt;COUNTERTOP = current_mtop + 100;

            seq_values_new.channel_0 = NRF_PWM0-&amp;gt;COUNTERTOP /2;

            nrf_pwm_values_t new_pwm_values; 

            new_pwm_values.p_individual = &amp;amp;seq_values_new;

            nrf_drv_pwm_sequence_values_update(&amp;amp;m_pwm0,1,new_pwm_values);

         }

    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM modulation frequency or modulation amplitude</title><link>https://devzone.nordicsemi.com/thread/156049?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 03:00:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74896095-467b-4755-bb24-353355e336e6</guid><dc:creator>creator</dc:creator><description>&lt;p&gt;Hello, thank you for your reply. It&amp;#39;s known that you want to change. top_value = m_demo1_top. This value needs to be restarted to the initial pwm. I don&amp;#39;t know if it&amp;#39;s right. How to restart the initial pwm? Is it okay to start the PWM in the interruption?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM modulation frequency or modulation amplitude</title><link>https://devzone.nordicsemi.com/thread/155878?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 08:45:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3b57c41-69d3-4212-b202-da6bd65002f2</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The desired pwm frequency is given by the formula&amp;nbsp;&lt;/span&gt;&lt;code&gt;F(pwm) = F(base_clock) / top_value&lt;/code&gt;&lt;span&gt;. So your idea of increasing the m_demo1_top is correct. Note that the max top_value is 32767.&lt;/span&gt;&lt;/p&gt;
[quote user=""]M_demo1_top is added from zero to 10000, but no PWM has no output.[/quote]
&lt;p&gt;&amp;nbsp;When does this happen? When&amp;nbsp;M_demo1_top reaches 10000?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>