<?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 Tolerance</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/96558/pwm-tolerance</link><description>nRF52840 
 NCS V 2.2.0 
 Using the NRFX drivers natively trying to set the PWM to 333uS. 
 over 20 different units i am seeing this vary form 326 to 335 
 what is the expected accuracy (tolerance) of the PWM output. 
 Is there an example of the PWM in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Feb 2023 13:27:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/96558/pwm-tolerance" /><item><title>RE: PWM Tolerance</title><link>https://devzone.nordicsemi.com/thread/409607?ContentTypeID=1</link><pubDate>Mon, 13 Feb 2023 13:27:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26a3a55e-305d-40c9-8d2e-47ac107940ed</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;You start the HFXO manually either by writing directly to the register:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Start 64 MHz crystal oscillator.
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;

// Wait for the external oscillator to start up.
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
{
// Do nothing.
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or by doing as clock_init() does &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/d29f1ddec99b81a66af93b7f0882a7bd0dfa30ee/samples/bluetooth/direct_test_mode/src/dtm.c#L497-L527"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Tolerance</title><link>https://devzone.nordicsemi.com/thread/409603?ContentTypeID=1</link><pubDate>Mon, 13 Feb 2023 13:19:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d575140a-ebc0-4e4e-98a9-0662d325a74c</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;Thanks.&amp;nbsp; If not set and using the HFINT.&amp;nbsp; How do i set this to use the HFXO in Zephyr?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Tolerance</title><link>https://devzone.nordicsemi.com/thread/409601?ContentTypeID=1</link><pubDate>Mon, 13 Feb 2023 13:18:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a099ec76-fe21-47c3-9ade-0b7fdff6b6d6</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi Wes,&lt;/p&gt;
&lt;p&gt;Can you check what HFCLK source the PWM is using? Is it HFINT or HFXO? You can check the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/clock.html?cp=5_0_0_4_3_2_16#register.HFCLKSTAT"&gt;HFSTAT &lt;/a&gt;register to what hf clock source that is used and if the HFCLK is running or not. At least in nRF5SDK, the PWM module would use the less accurate HFINT if the HFXO wasn&amp;#39;t started&amp;nbsp;explicitly beforehand. The tolerance of the PWM depends on the clock source that is used.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Examples using the nrfx drivers directly can be found &lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_pwm"&gt;here&lt;/a&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><item><title>RE: PWM Tolerance</title><link>https://devzone.nordicsemi.com/thread/409414?ContentTypeID=1</link><pubDate>Fri, 10 Feb 2023 19:55:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:426c9a12-25d4-4cbe-9f42-73b4e9ff4695</guid><dc:creator>WesC</dc:creator><description>&lt;p&gt;I found this example, but haven&amp;#39;t had a chance to test it.&amp;nbsp; This is very similar to my code.&amp;nbsp; I will run tests, but can you do similar to see how well it holds tolerance to 333us.&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ncs_2D00_nrfx_2D00_pwm_2D00_simple_2D00_example_2D00_master.zip"&gt;devzone.nordicsemi.com/.../ncs_2D00_nrfx_2D00_pwm_2D00_simple_2D00_example_2D00_master.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;would this be the suggested way to use the NRFX drivers for the PWM.&lt;/p&gt;
&lt;p&gt;If i use Zephyr and use something like PWM-LEDs for some other reason work better?&lt;/p&gt;
&lt;p&gt;finally how do i determine if i am running from the HFCLK?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>