<?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>About nrf52832 automatic frequency conversion output</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/40115/about-nrf52832-automatic-frequency-conversion-output</link><description>Hello, I want to use nrf52832 to output waveforms as shown above. 
 Using the Demo1 example in D: Lianxi nordic nRF5_SDK_12.2.0_f012efa examples peripheral pwm_driver, we want to change the frequency output, from large to small, and then from small to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Nov 2018 05:36:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/40115/about-nrf52832-automatic-frequency-conversion-output" /><item><title>RE: About nrf52832 automatic frequency conversion output</title><link>https://devzone.nordicsemi.com/thread/156793?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 05:36:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1dc7aaa-48c7-4d65-93b0-877cf42b5430</guid><dc:creator>creator</dc:creator><description>&lt;p&gt;Hello, nrf52832 does need to change the frequency PWM output, your program help, thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About nrf52832 automatic frequency conversion output</title><link>https://devzone.nordicsemi.com/thread/156210?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 16:02:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd13b056-a1cb-41dd-beb1-8e044468ecc6</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry my bad, I thought you meant duty cycle. Take a look at Rune&amp;#39;s answer in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/31035/how-to-change-pwm-frequency/122532#122532"&gt;this similar devzone post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;With the PWM hardware the top value is set during init so you will need to uninit and init each time you change it.&lt;/p&gt;
&lt;p&gt;I will need some time to test the code for a solution using timers, GPIOTE and PPI if you want to go that way.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About nrf52832 automatic frequency conversion output</title><link>https://devzone.nordicsemi.com/thread/156048?ContentTypeID=1</link><pubDate>Tue, 06 Nov 2018 02:56:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8713be07-1c03-4027-a31b-68beae58f8b6</guid><dc:creator>creator</dc:creator><description>&lt;p&gt;Hello, thank you for your reply, this is changing the duty cycle, and I want to change the frequency. Is there any way?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About nrf52832 automatic frequency conversion output</title><link>https://devzone.nordicsemi.com/thread/155976?ContentTypeID=1</link><pubDate>Mon, 05 Nov 2018 13:40:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5728f63b-7fc4-4deb-9933-2f293c01f289</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can modify demo1 to increase and decrease the ouput just in one channel. See the following code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void demo1_handler(nrf_drv_pwm_evt_type_t event_type)
{

	
    if (event_type == NRF_DRV_PWM_EVT_FINISHED)
    {
//        uint8_t channel    = m_demo1_phase &amp;gt;&amp;gt; 1;
        bool    down       = m_demo1_phase &amp;amp; 1;
        bool    next_phase = false;

        uint16_t * p_channels = (uint16_t *)&amp;amp;m_demo1_seq_values;
 //     uint16_t   value      = p_channels[channel];
				uint16_t value = m_demo1_seq_values.channel_0;
        if (down)
        {
            value -= m_demo1_step;
            if (value == 0)
            {
                next_phase = true;
            }
        }
        else
        {
            value += m_demo1_step;
            if (value &amp;gt;= m_demo1_top)
            {
                next_phase = true;
            }
        }
				m_demo1_seq_values.channel_0 = value;
        //p_channels[channel] = value;

        if (next_phase)
        {
            if (++m_demo1_phase &amp;gt;= 2 * NRF_PWM_CHANNEL_COUNT)
            {
                m_demo1_phase = 0;
            }
        }
    }
}


static void demo1(void)
{
    NRF_LOG_INFO(&amp;quot;Demo 1\r\n&amp;quot;);

    /*
     * This demo plays back a sequence with different values for individual
     * channels (LED 1 - LED 4). Only four values are used (one per channel).
     * Every time the values are loaded into the compare registers, they are
     * updated in the provided event handler. The values are updated in such
     * a way that increase and decrease of the light intensity can be observed
     * continuously on succeeding channels (one second per channel).
     */

    uint32_t                   err_code;
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
//            BSP_LED_1 | NRF_DRV_PWM_PIN_INVERTED, // channel 1
//            BSP_LED_3 | NRF_DRV_PWM_PIN_INVERTED, // channel 2
//            BSP_LED_2 | NRF_DRV_PWM_PIN_INVERTED  // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOWEST,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = m_demo1_top,
        .load_mode    = NRF_PWM_LOAD_INDIVIDUAL,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    err_code = nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, demo1_handler);
    APP_ERROR_CHECK(err_code);
    m_used |= USED_PWM(0);

    m_demo1_seq_values.channel_0 = 0;
//    m_demo1_seq_values.channel_1 = 0;
//    m_demo1_seq_values.channel_2 = 0;
//    m_demo1_seq_values.channel_3 = 0;
    m_demo1_phase                = 0;

    nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;m_demo1_seq, 1,
                                NRF_DRV_PWM_FLAG_LOOP);
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>