<?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>How to modify the PWM value with easydma   for NRF52???</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15885/how-to-modify-the-pwm-value-with-easydma-for-nrf52</link><description>now，I want to use a serial port to transmit data, to change the duty and cycle of PWM .</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Aug 2016 15:17:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15885/how-to-modify-the-pwm-value-with-easydma-for-nrf52" /><item><title>RE: How to modify the PWM value with easydma   for NRF52???</title><link>https://devzone.nordicsemi.com/thread/60586?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2016 15:17:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e62612a-d513-41fc-9182-04212b0655bc</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;then you have to set the load to waveform (see &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=2_2_0_46_1#concept_wxj_hnw_nr"&gt;product specification&lt;/a&gt; for how this works):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.load_mode    = PWM_DECODER_LOAD_WaveForm
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And use &lt;code&gt;nrf_pwm_values_wave_form_t&lt;/code&gt; struct for the values.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to modify the PWM value with easydma   for NRF52???</title><link>https://devzone.nordicsemi.com/thread/60587?ContentTypeID=1</link><pubDate>Tue, 23 Aug 2016 03:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce964dd3-6619-4a7e-bb2a-037e5637ab89</guid><dc:creator>Zkernel</dc:creator><description>&lt;p&gt;Thank you very much, duty than I can be changed. now  ，i want  change the cycle?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  typedef struct
{
    uint16_t period  ;
    nrf_pwm_values_grouped_t  P_groups; 
} nrf_pwm_running_values; 

static nrf_pwm_running_values nrf_pwm={10000,{100,100|0x8000}};


 static nrf_pwm_sequence_t const pwm0_seq =
    {
        .values.p_grouped = &amp;amp;nrf_pwm.P_groups,
        .length           = 2,
        .repeats          = 0,
        .end_delay        = 0
    };
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is my definition of a cycle and duty cycle of the structure, when I serial interface to modify the structure，but cycle has not changed.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
    for (uint32_t i = 0; i &amp;lt; length; i++)
    {
        while(app_uart_put(p_data[i]) != NRF_SUCCESS);
        SEGGER_RTT_printf(0,&amp;quot;UART DATA %02X \n\n&amp;quot;,p_data[i]) ; 
    }
    nrf_pwm.period=20000;
    nrf_pwm.P_groups.group_0=200;
    nrf_pwm.P_groups.group_1=200|0x8000;
    nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;pwm0_seq, 1,
    NRF_DRV_PWM_FLAG_LOOP);
    while(app_uart_put(&amp;#39;\n&amp;#39;) != NRF_SUCCESS);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to modify the PWM value with easydma   for NRF52???</title><link>https://devzone.nordicsemi.com/thread/60585?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2016 14:50:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b56b886c-0d86-4785-818e-44258a27f20c</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;This code will setup PWM on one pin. You can update the duty cycle between 0 and m_top:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint16_t const m_top  = 10000;

static nrf_pwm_values_common_t m_seq_values;
static nrf_pwm_sequence_t const m_seq =
{
    .values.p_common    = &amp;amp;m_seq_values,
    .length              = NRF_PWM_VALUES_LENGTH(m_seq_values),
    .repeats             = 0,
    .end_delay           = 0
};

static void pwm_init(void)
{
    uint32_t err_code;
    nrf_drv_pwm_config_t const config0 =
    {
        .output_pins =
        {
            BSP_LED_0 | NRF_DRV_PWM_PIN_INVERTED, // channel 0
            NRF_DRV_PWM_PIN_NOT_USED, // channel 1
            NRF_DRV_PWM_PIN_NOT_USED, // channel 2
            NRF_DRV_PWM_PIN_NOT_USED  // channel 3
        },
        .irq_priority = APP_IRQ_PRIORITY_LOW,
        .base_clock   = NRF_PWM_CLK_1MHz,
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = m_top,
        .load_mode    = NRF_PWM_LOAD_COMMON,
        .step_mode    = NRF_PWM_STEP_AUTO
    };
    err_code = nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, NULL);
    APP_ERROR_CHECK(err_code);
    m_used |= USED_PWM(0);
}

void update_pwm(int16_t duty_cycle)
{
    m_seq_values = duty_cycle;
    nrf_drv_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;m_seq, 1, 0);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>