<?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>Recommended nRF52805 peripheral(s) and Zephyr RTOS features to generate high frequency and low frequency clocks</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113464/recommended-nrf52805-peripheral-s-and-zephyr-rtos-features-to-generate-high-frequency-and-low-frequency-clocks</link><description>Hello! 
 
 I am using an nRF52805 for a custom board design and I am hoping to get some advice on selecting peripherals and Zephyr features that would best meet my system requirements. I&amp;#39;ll provide specific details below, but the high level requirements</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 Aug 2024 14:42:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113464/recommended-nrf52805-peripheral-s-and-zephyr-rtos-features-to-generate-high-frequency-and-low-frequency-clocks" /><item><title>RE: Recommended nRF52805 peripheral(s) and Zephyr RTOS features to generate high frequency and low frequency clocks</title><link>https://devzone.nordicsemi.com/thread/498668?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2024 14:42:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2f61e12-cd1f-46b6-a7de-c14efb1fddcf</guid><dc:creator>ParkerMcD</dc:creator><description>&lt;p&gt;Excellent. I will make use of the nrfx_driver API to configure the GPIOTE for clock generation. Thanks for the help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Recommended nRF52805 peripheral(s) and Zephyr RTOS features to generate high frequency and low frequency clocks</title><link>https://devzone.nordicsemi.com/thread/498541?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2024 06:14:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d949d44-f9f2-42c4-bb07-a6e54957d190</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="ParkerMcD"]Are there any good Zephyr samples in the v2.6.1 SDK that you would recommend I start from?[/quote]
&lt;p&gt;I do not see any samples but maybe the code from the old sdk can help you understand the jist of it.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; int main(void)
 {
 nrf_gpio_range_cfg_output(18); //Configure pin 18 as output

 NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1; //Start high frequency clock
 while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
 {
      //Wait for HFCLK to start
 }
 NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0; //Clear event
 
 
 //Configure GPIOTE to toggle pin 18 
 NRF_GPIOTE-&amp;gt;CONFIG[0] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos |
                         GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos |
                         18 &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                         GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;
 
 //Configure timer
 NRF_TIMER1-&amp;gt;PRESCALER = 0;
 NRF_TIMER1-&amp;gt;CC[0] = 1;  // Adjust the output frequency by adjusting the CC.
 NRF_TIMER1-&amp;gt;SHORTS = TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos;
 NRF_TIMER1-&amp;gt;TASKS_START = 1;
 
 //Configure PPI
 NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t) &amp;amp;NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0];
 NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t) &amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];
 
 NRF_PPI-&amp;gt;CHENSET = PPI_CHENSET_CH0_Enabled &amp;lt;&amp;lt; PPI_CHENSET_CH0_Pos;
 
 while (true)
 {
     // do nothing
 }
 }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In Zephyr, since we do not want to access registers directly, you need to achieve the above using &lt;a href="https://github.com/NordicSemiconductor/nrfx/tree/master/drivers"&gt;nrfx_ driver API&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Recommended nRF52805 peripheral(s) and Zephyr RTOS features to generate high frequency and low frequency clocks</title><link>https://devzone.nordicsemi.com/thread/498496?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2024 16:33:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fd77947-04e2-4c3d-ad2c-9342c308eaea</guid><dc:creator>ParkerMcD</dc:creator><description>&lt;p&gt;Excellent thank you! I am working on implementing the HF and LF clocks using the HFINT/HFXO and GPIOTE peripherals. I will post updates when I have it working.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are there any good Zephyr samples in the v2.6.1 SDK that you would recommend I start from?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Recommended nRF52805 peripheral(s) and Zephyr RTOS features to generate high frequency and low frequency clocks</title><link>https://devzone.nordicsemi.com/thread/496263?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2024 14:46:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15f7f89c-b967-4136-a46e-4b70c999ffe6</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Parker,&lt;/p&gt;
[quote user=""]&lt;b&gt;For the HFCLK: &lt;/b&gt;1) Are there any recommended peripherals on the nRF52805 I could use to generate a 1-1.5 MHz clock&amp;nbsp; with minimal CPU intervention? e.g. GPIOTE, SPI etc. 2) Are there any Zephyr examples of generating a clock that you recommend I start with and modify? 3) Would be possible to just use a hardware timer + ISR to generate this clock with manual GPIO toggling?[/quote]
&lt;p&gt;The nRF52805 supports a variety of peripherals that can be used to generate a clock signal. The HFCLK controller provides several high frequency clock (HFCLK) sources, including a 64 MHz internal oscillator (HFINT) and a 64 MHz crystal oscillator (HFXO). However, to generate a 1-1.5 MHz clock, you might need to calibrate the prescaler orf timer peripheral. The GPIOTE (GPIO Task and Event) peripheral can be used to toggle GPIO pins without CPU intervention. There are many variations of this attempt similar to what is shown in &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/79755/nrf5340dk-8hmz-clock-output-to-gpio-pin-example-via-gpiote-ppi-timer"&gt;this &lt;/a&gt;thread. But having specific duty cycle and interval is something that you need to play with the prescaler of the timer to achieve what you need.&lt;/p&gt;
&lt;p&gt;The other option is using &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/89055/creating-clock-signal-for-another-ic-using-pwm"&gt;PWM&amp;nbsp;&lt;/a&gt;which can give you more configuration power to achieve different duty cycle on the clock.&lt;/p&gt;
[quote user=""]&lt;b&gt;For the LFCLKs: &lt;/b&gt;1) Would you recommend using a peripheral (e.g. GPIOTE), or utilize something like a timer + ISR + software counters to toggle GPIO to generate these clocks? 2) Are there any Zephyr examples of implementing something similar to this that you could recommend I start with?[/quote]
&lt;p&gt;You do not need to do anything in ISR to generate a LFCLK using HFCLK. As mentioned above, this can be purely done without CPU iintervention just by using GPIOTE+PPI+TIMER or PWM. The only draw back is that these configurations will keep the HFCLK always active which is power intensive configuration.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>