<?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>Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67745/generated-arbitrary-wave-with-pwm-controller</link><description>Is there a way to generate a square wave like the one in the picture without using any kind of interruption to change settings middle-wave? 
 
 For example, the wave can be 50ms on, 25 ms off, 50ms on, 25ms off, 150ms on, and then the sequence is over</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 01 Dec 2020 19:14:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67745/generated-arbitrary-wave-with-pwm-controller" /><item><title>RE: Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/thread/282755?ContentTypeID=1</link><pubDate>Tue, 01 Dec 2020 19:14:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:154ec731-cf39-4238-b477-4fb5a93d2347</guid><dc:creator>Jose Cazarin</dc:creator><description>&lt;p&gt;Going back at this with a quick question: is it possible to PAUSE the generation of said arbitrary wave and then resume from where it left off later?&lt;br /&gt;Was looking at the SDK but looks like that&amp;#39;s not possible, I can just stop it and restart from the beginning since there is a method called &amp;quot;nrf_drv_pwm_stop&amp;quot; but not something like &amp;quot;nrf_drv_pwm_pause&amp;quot;&lt;br /&gt;Thank you so much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/thread/277759?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 09:26:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44a0596a-40ca-42de-b3a7-5b903640202f</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Awesome, good job! :D&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/thread/277692?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 23:41:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09352def-7500-466d-90f3-6cd9732f4ede</guid><dc:creator>Jose Cazarin</dc:creator><description>&lt;p&gt;That was a bug in my logic, it is working now, thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/thread/277690?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 22:17:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6c68ec44-4e82-4ee5-b341-c8f57f209c05</guid><dc:creator>Jose Cazarin</dc:creator><description>&lt;p&gt;Thank you! That worked&lt;br /&gt;Taking a look at the demo4 example also helped a lot&lt;br /&gt;Another question: is it possible to change the contents of the&amp;nbsp;nrf_pwm_values_common_t array at runtime?&lt;br /&gt;I&amp;#39;m using this to generate a vibration pattern on a device and I would like to be able to change that pattern at runtime&lt;br /&gt;But when I change the contents of that array, the pattern stays the same. However, If I reboot the board, the new pattern then kicks in&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generated arbitrary wave with PWM controller</title><link>https://devzone.nordicsemi.com/thread/277620?ContentTypeID=1</link><pubDate>Thu, 29 Oct 2020 13:50:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd946dce-ed3a-499f-b13f-067e37dd5c4a</guid><dc:creator>haakonsh</dc:creator><description>[quote user=""]I&amp;#39;m reading the doc on the PWM controller, but I&amp;#39;m not sure how to do something like that. How can I set the different periods (the 50, 25, and 150 ms)?[/quote]
&lt;p&gt;&amp;nbsp;I suggest you read the&amp;nbsp;&lt;a title="PWM" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/hardware_driver_pwm.html?cp=7_1_2_0_8"&gt;PWM&lt;/a&gt;&amp;nbsp;driver documentation and&amp;nbsp;&lt;a title="PWM driver" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__pwm.html?cp=7_1_6_8_0_24_1"&gt;PWM driver&lt;/a&gt;&amp;nbsp;API documentation, and then go through the&amp;nbsp;&lt;a title="PWM Driver Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/pwm_hw_example.html?cp=7_1_4_6_24"&gt;PWM Driver Example&lt;/a&gt;&amp;nbsp;in order to familiarize yourself with the PWM peripheral.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You&amp;#39;ll need to use the arbitrary waveform generator, it sounds fanzy, but it&amp;#39;s actually fairly simple to use. Include the given&amp;nbsp;&lt;span&gt;COUNTERTOP value in the given Sequence as shown in figure 4 in&amp;nbsp;&lt;a title="Decoder with EasyDMA" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/pwm.html?cp=4_2_0_46_1#concept_wxj_hnw_nr"&gt;Decoder with EasyDMA&lt;/a&gt;.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;The idea is to break down your signal into sequences of PWM periods, where each Sequence sample is one PWM period. In this case X + A, Y + B, and Z + &amp;quot;Zend&amp;quot; are each a full PWM period with countertop values of X + A, Y + B, Z+Zend, and compare values of X, Y, and Z respectively. &lt;br /&gt;In this case Zend is an imagined construct to fit the last pulse to a PWM period. If you set countertop = Z and Zend=0 you&amp;#39;ll get a PWM period of length Z and 100% duty-cycle.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>