<?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>Generating 50% duty cycle square waves greater than 1Mhz using PWM.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92387/generating-50-duty-cycle-square-waves-greater-than-1mhz-using-pwm</link><description>Hello, 
 I am attempting to use my nRF52810 (testing with the nRF52 DK) to generate square waves using PWM. Ideally, these square waves would operate at 8 or 16Mhz. So far I have used the base pwm_library and pwm_driver examples provided in the sdk to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Sep 2022 17:43:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92387/generating-50-duty-cycle-square-waves-greater-than-1mhz-using-pwm" /><item><title>RE: Generating 50% duty cycle square waves greater than 1Mhz using PWM.</title><link>https://devzone.nordicsemi.com/thread/388630?ContentTypeID=1</link><pubDate>Thu, 29 Sep 2022 17:43:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62af65b9-0fb6-4e85-9074-46b73f40edab</guid><dc:creator>himothy</dc:creator><description>&lt;p&gt;Thanks for the follow up Sigurd.&lt;/p&gt;
&lt;p&gt;Setting the GPIO pin in high drive mode makes the waveform &amp;quot;more square.&amp;quot; But a bit more of a clipped sine wave than a square wave. It also increases the amplitude too.&lt;/p&gt;
&lt;p&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/pastedimage1664473265980v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating 50% duty cycle square waves greater than 1Mhz using PWM.</title><link>https://devzone.nordicsemi.com/thread/388477?ContentTypeID=1</link><pubDate>Thu, 29 Sep 2022 07:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57d56da9-6469-4f77-8e29-bb99a8682fca</guid><dc:creator>Sigurd</dc:creator><description>[quote user="himothy"]Would just like to confirm that 8Mhz is the highest frequency achievable.[/quote]
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, this is the highest you can get.&lt;/p&gt;
[quote user="himothy"]Is there any way to adjust the waveform shape so that the output is more square?[/quote]
&lt;p&gt;Maybe if you set the GPIO pin in high drive mode.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrf_gpio_cfg(pin_number, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, NRF_GPIO_PIN_NOPULL, &lt;strong&gt;NRF_GPIO_PIN_H0H1&lt;/strong&gt;, NRF_GPIO_PIN_NOSENSE);&lt;/span&gt;&lt;/p&gt;
[quote user="himothy"]Additionally, can the amplitude of the waveform be adjusted?[/quote]
&lt;p&gt;No, it should be around ~VDD&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating 50% duty cycle square waves greater than 1Mhz using PWM.</title><link>https://devzone.nordicsemi.com/thread/388431?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2022 20:15:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:878215e4-52ab-4b96-80d5-3f2dfdce4125</guid><dc:creator>himothy</dc:creator><description>&lt;p&gt;Thanks for the help Sigurd. Very helpful and much appreciated.&lt;/p&gt;
&lt;p&gt;Would just like to confirm that 8Mhz is the highest frequency achievable. There is no way to generate a higher frequency (16Mhz)?&lt;/p&gt;
&lt;p&gt;I used the example you linked above and was able to generate a 8Mhz waveform.&lt;/p&gt;
&lt;p&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/pastedimage1664395952780v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Is there any way to adjust the waveform shape so that the output is more square? Additionally, can the amplitude of the waveform be adjusted?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generating 50% duty cycle square waves greater than 1Mhz using PWM.</title><link>https://devzone.nordicsemi.com/thread/388335?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2022 11:49:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e535d60c-ca2a-423a-b4a3-99cacf89bf8c</guid><dc:creator>Sigurd</dc:creator><description>[quote user=""]&lt;p&gt;1) What is the max frequency output achievable using PWM (is it 16Mhz)?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;&lt;span&gt;Using the PWM HW peripheral, then lowest allowed .top_value is&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html#register.COUNTERTOP"&gt;3&lt;/a&gt;&lt;span&gt;, so the max frequency you can get with the PWM peripheral is 16(base or prescaler)/3(countertop) = 5.3333 MHz.&lt;/span&gt;&lt;/p&gt;
[quote user=""]2) How can I achieve this (or 8Mhz/16Mhz)? An example would be greatly appreciated.[/quote]
&lt;p&gt;Using GPIOTE+TIMER+PPI, it possible to get max 8 MHz with duty ~50%. See e.g. this post:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/12177/nrf52-clock-in-and-out"&gt;nRF52 clock in and out&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>