<?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>Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78591/frequency-not-read-for-nrfx-pwm-peripheral-in-waveform-mode</link><description>Dear Sirs, 
 
 SDK: NCS version 1.6.0 
 Board: nrf5340 DK 
 IDE: SES Nordic Edition V5.50c 
 Compiled in application core cpuappns 
 
 I am a beginner with nrf programming trying to learn how to use the PWM peripheral through the nrfx drivers. 
 Normal</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 20 Aug 2021 08:34:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78591/frequency-not-read-for-nrfx-pwm-peripheral-in-waveform-mode" /><item><title>RE: Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/thread/325867?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 08:34:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b121387-092d-4517-9cb8-345d9cb9a98d</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Attached is the complete project. Build and flash it to your nRF5340 and see if you can measure the signal on pin P0.04.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ncs_5F00_pwm.7z"&gt;devzone.nordicsemi.com/.../ncs_5F00_pwm.7z&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/thread/325518?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 12:53:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd2ae86a-8bca-438d-a5f5-b36eecdf0e37</guid><dc:creator>JonasForssell</dc:creator><description>&lt;p&gt;Very interesting!&lt;br /&gt;&lt;br /&gt;This program does not output anything on pin 0.04 for me and the LED is still blinking with a strange duty cycle at 1000Hz. It complies fine.&lt;br /&gt;&lt;br /&gt;Are there any particular build options I should enable perhaps in the project which I have missed?&lt;br /&gt;If i go to project and select &amp;quot;Configure nrf Connect SDK Project&amp;quot; - select menuconfig, I can see that both GPIO drivers and PWM drivers are selected.&lt;br /&gt;&lt;br /&gt;As an additional information, I can control any pin - everything works as expected - when I bypass the drivers all together and program the hardware directly.&lt;/p&gt;
&lt;p&gt;/Jonas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/thread/325414?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 07:42:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29a637a9-5f62-45ee-b414-4463599d7f6b</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;lt;nrfx_pwm.h&amp;gt;
#include &amp;lt;zephyr.h&amp;gt;

// Use Zephyr macro to get access to the LED0 on the board
//#define OUTPUT_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios)

// Use nrfx to create a PWM instance which we will connect to the LED0 later
static nrfx_pwm_t m_pwm0 = NRFX_PWM_INSTANCE(0);

// Declare variables holding PWM sequence values. In this example only one channel is used 
// We start off with a counter to 50 and a top value of 100 giving a 50% duty cyle.
nrf_pwm_values_wave_form_t seq_values[] = {50, 0, 0, 100};

nrf_pwm_sequence_t const seq =
{
    .values.p_wave_form = seq_values,
    .length          = NRF_PWM_VALUES_LENGTH(seq_values),
    .repeats         = 0,
    .end_delay       = 0
};


nrfx_pwm_config_t const config0 =
    {
        .output_pins =
        {
            4,                        // channel 0 now connected to LED0
            NRFX_PWM_PIN_NOT_USED,             // channel 1
            NRFX_PWM_PIN_NOT_USED,             // channel 2
            NRFX_PWM_PIN_NOT_USED,             // channel 3
        },
        .irq_priority = NRFX_PWM_DEFAULT_CONFIG_IRQ_PRIORITY,
        .base_clock   = NRF_PWM_CLK_1MHz,       // Here we select which prescaler to use
        .count_mode   = NRF_PWM_MODE_UP,
        .top_value    = 100,                    // This is ignored when in wave form mode
        .load_mode    = NRF_PWM_LOAD_WAVE_FORM,
        .step_mode    = NRF_PWM_STEP_AUTO
    };

int main(void) {

// Init PWM without error handler
nrfx_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, NULL, NULL);

// Set and start
nrfx_pwm_simple_playback(&amp;amp;m_pwm0, &amp;amp;seq, 1, NRFX_PWM_FLAG_LOOP);

while(1) 
    k_msleep(3000);

}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/thread/325398?ContentTypeID=1</link><pubDate>Wed, 18 Aug 2021 06:53:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1017d1d-2d7a-49b3-98e3-fd9553e3d7ed</guid><dc:creator>JonasForssell</dc:creator><description>&lt;p&gt;Thank you for your reply Jared.&lt;br /&gt;Would you mind posting your modified code that you tried so that I can replicate this on my board and oscilloscope?&lt;br /&gt;&lt;br /&gt;I have measured the PWM signal on pin 28 which also is connected to the LED.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Frequency not read for nrfx PWM peripheral in WaveForm mode</title><link>https://devzone.nordicsemi.com/thread/325248?ContentTypeID=1</link><pubDate>Tue, 17 Aug 2021 09:06:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7bd48aab-8943-4a87-bbf4-a79815d3af4b</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi there!&lt;/p&gt;
&lt;p&gt;I tried your example on my nRF5340 DK, the only change I did was to change the pin to P0.04 so that I could probe the signal with my logic analyzer. As you can see from trace, it actually produces a 10 kHz signal. How did you measure your signal?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1629191051174v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;Maybe I misunderstood your&amp;nbsp;&lt;/span&gt;&lt;span&gt;problem&lt;/span&gt;&lt;span&gt;?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>