<?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 API&amp;#39;s</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/94132/pwm-api-s</link><description>hi team, 
 I using nrf52840DK controller and nRF5_SDK_17.1.0. I want to change PWM module Frequency dynamically (it has to change frequency automatically) at different time instants. 
 Is there any APIs or reference example code to achieve the task? </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 28 Nov 2022 11:17:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/94132/pwm-api-s" /><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/397832?ContentTypeID=1</link><pubDate>Mon, 28 Nov 2022 11:17:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbae328e-a3fd-4cb4-8e81-86b2a567c738</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="kunchalaRajesh"] i tried without delay i am getting fatal error[/quote]
&lt;p&gt;I would not expect a delay to be needed, but it would be interesting to know what happens. As stated, you can check what the &amp;quot;fatal error&amp;quot; really was as explained in my previous post.&amp;nbsp;That needs to be done in order to know what happened. Once you know which function returned which error code, you can look more into the details.&lt;/p&gt;
[quote user="kunchalaRajesh"]this controller gpios have a capacity to sense 1000 interrupts per sec can you please explain why i getting&amp;nbsp;&amp;nbsp;fluctuation.[/quote]
&lt;p&gt;Which fluctuations are you describing now? What is the problem? If you are loogging too much/fast it could be that you loose some&amp;nbsp;UART data, if that is what you are seeing and asking about. That is not unexpected.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PS: Please share code by using Insert -&amp;gt; Insert Code instead of screenshots. That makes it much easier to get a full picture.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/397752?ContentTypeID=1</link><pubDate>Sat, 26 Nov 2022 17:51:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59b4e92b-330f-477b-9f64-acb45eae96a2</guid><dc:creator>kunchalaRajesh</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi, actually i have another doubt.i am getting&amp;nbsp;fluctuation in terminal emulator and debug terminal while printing pwm output frequency. can this controller gpios have a capacity to sense 1000 interrupts per sec can you please explain why i getting&amp;nbsp;&amp;nbsp;fluctuation. is it&amp;nbsp; gpios problem or terminal output problem or my code problem. please explain me.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-_2800_28_2900_.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3343.Screenshot-_2800_29_2900_.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/4024.Screenshot-_2800_30_2900_.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot-_2800_27_2900_.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/0726.Screenshot-_2800_26_2900_.png" alt=" " /&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/1307.Screenshot-_2800_25_2900_.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/WhatsApp-Image-2022_2D00_11_2D00_26-at-10.55.43-PM.jpeg" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/397751?ContentTypeID=1</link><pubDate>Sat, 26 Nov 2022 17:20:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a76f4137-b224-444f-9179-b6ca97c44892</guid><dc:creator>kunchalaRajesh</dc:creator><description>&lt;p&gt;Hi, actually i have one doubt . Is it mandatory to provide software delay between&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;nrfx_pwm_uninit()&amp;nbsp; and&amp;nbsp;nrfx_pwm_init()? without delay can not we switch? because i tried without delay i am getting fatal error and also i am getting fatal error whenever i am using hardware timer also.&amp;nbsp; But i am getting exact output with software delay only. why like that? may i know the reason. And why&amp;nbsp; i am not getting output with hardware timers. also i am not understanding what is the meaning of fatal error and in which case this type of errors occurs . can you please explain.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3005.Screenshot-_2800_8_2900_.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/397426?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 12:46:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0125bc7-840f-41bc-8e43-b4b62b2f4f80</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;When you see &amp;quot;Fatal error&amp;quot; that means that an APP_ERROR_CHECK has been called with an error code. If you make a debug build and run again you should see an extended output with file name and line number, so that you can know which function returned which error code. (To get a debug build, define DEBUG for the project or select the Debug build target if using an&amp;nbsp;example&amp;nbsp;SES project as starting point).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/397407?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2022 12:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:792fb080-0613-470d-b234-af1875343c47</guid><dc:creator>kunchalaRajesh</dc:creator><description>&lt;p&gt;Thank you for the response. We have tried using&amp;nbsp;&lt;span&gt;nrfx_pwm_uninit() first and&amp;nbsp;nrfx_pwm_init() next. However, when I tried to flash on the controller board, it displays &amp;quot;Fatal error&amp;quot; in the logger.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;please help.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM API's</title><link>https://devzone.nordicsemi.com/thread/396909?ContentTypeID=1</link><pubDate>Tue, 22 Nov 2022 12:52:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05e34c73-5d2e-4554-a0e6-ccdb5d92a957</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]what is the difference between &lt;a title="PWM driver - legacy layer" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__drv__pwm.html?cp=8_5_4_6_9_0_12_0"&gt;PWM driver - legacy layer&lt;/a&gt;,&amp;nbsp;&lt;a title="PWM driver" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrfx__pwm.html?cp=8_5_4_6_9_0_12_1"&gt;PWM driver&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a title="PWM HAL" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__pwm__hal.html?cp=8_5_4_6_9_0_12_2"&gt;PWM HAL&lt;/a&gt;&amp;nbsp;APIs?[/quote]
&lt;p&gt;The PWM HAL is a set of low level functions for reading and writing to the WPM registers. The nrfx PWM driver contains the implementation of the higher level driver. And the legacy layer / legacy driver is a shim or wrapper that provides the old nrf_drv_pwm API. In this case, it just redefines function names and type names, so it does not matter if you use the nrfx_ or nrf_drv API.&lt;/p&gt;
&lt;p&gt;(There are also other PWM libraries in the SDK that&amp;nbsp;implement&amp;nbsp;PWM using different methods, either TIMER and GPIOTE via PPI without software other than for setting up, or RTC and GPIO where SW needs to run for every pin state change).&lt;/p&gt;
[quote user=""]I want to change PWM module Frequency dynamically (it has to change frequency automatically) at different time instants.&amp;nbsp;[/quote]
&lt;p&gt;When using the PWM peripheral, the frequency is given by the PRESCALER value. Using the driver this is set by the base_clock parameter in the&amp;nbsp;nrfx_pwm_config_t struct that you pass to&amp;nbsp;nrfx_pwm_init() if using the nrfx API (if using the nrf_drv the names will be different, but all else the same). To adjust this via the driver you need to call&amp;nbsp;nrfx_pwm_uninit() first, then call&amp;nbsp;nrfx_pwm_init() again with a modified struct with a different base_clock.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>