<?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>Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/98880/using-pwm-peripheral-to-output-fixed-number-of-pulses</link><description>I am attempting to control 3x stepper motor drivers with a STEP + DIR inputs. For this I need to be able to create a pulse train with 50% duty cycle with a fixed number of pulses. It appears there should be a way to do this with the PWM peripheral (1</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Apr 2023 08:43:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/98880/using-pwm-peripheral-to-output-fixed-number-of-pulses" /><item><title>RE: Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/thread/421965?ContentTypeID=1</link><pubDate>Mon, 24 Apr 2023 08:43:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb1dbd37-4521-46a4-b66e-ded0b102a2ca</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know how this stepper motor signal looks like, but maybe it&amp;#39;s possible for you to use the QDEC to keep track of that&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/qdec.html?cp=5_0_0_5_17"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/qdec.html?cp=5_0_0_5_17&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/thread/421802?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2023 14:18:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:565abf13-412f-4299-b5a8-ae05bdc477d4</guid><dc:creator>jcondon</dc:creator><description>&lt;p&gt;This is unfortunate and precludes the use of the PWM for stepper motors. If you ever wanted the motor command to stop, change direction, or change the end position of the motor while a sequence is running, you would&amp;nbsp;lose the step count and have to re-home the motor.&lt;/p&gt;
&lt;p&gt;The only way I can see to accomplish this is using the EVENTS_PWMPERIODEND event and tie it to a&amp;nbsp;Timer&amp;#39;s TASKS_COUNT. However, we don&amp;#39;t have enough timer peripherals left for our application.&lt;/p&gt;
&lt;p&gt;We&amp;#39;ll have to move to a different processor line.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/thread/421660?ContentTypeID=1</link><pubDate>Fri, 21 Apr 2023 08:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50740007-d50a-460b-9872-e1cfe6c4aa1f</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="jcondon"]Is there a way to read what the current count/repeats (i.e. how many pulses) the PWM has sent out while it&amp;#39;s operating. Similarly is there a way to read out the number of pulses sent after STOP is issued?[/quote]
&lt;p&gt;Looking at the PWM chapter in the Product Specification, the PWM peripheral does not support this. You set the number of pulses you want to send, and you get an event when that have completed.&lt;/p&gt;
&lt;p&gt;Maybe you could use a&amp;nbsp;logic analyzer, and check that your FW implementation matches what you are trying to do with the&amp;nbsp;&lt;span&gt;logic analyzer.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/thread/421582?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2023 18:57:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ae3a036-1d8d-4e14-985e-8efbed4981be</guid><dc:creator>jcondon</dc:creator><description>&lt;p&gt;Nordic&amp;#39;s drivers are not written in a way that lends themself to our framework. We typically use the nrfx drivers as reference and adapt them to our purposes. However, let&amp;#39;s pretend I&amp;#39;m using them...&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is there a way to read what the current count/repeats (i.e. how many pulses) the PWM has sent out while it&amp;#39;s operating. Similarly is there a way to read out the number of pulses sent after STOP is issued?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using PWM peripheral to output fixed number of pulses</title><link>https://devzone.nordicsemi.com/thread/421416?ContentTypeID=1</link><pubDate>Thu, 20 Apr 2023 08:57:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a994b7c9-ea6f-4d06-a01e-26bf6914b98d</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]Note: Settings are being controlled directly through register writes[/quote]
&lt;p&gt;As a general note, I recommend using our drivers.&lt;/p&gt;
&lt;p&gt;You can see how your use-case is handled by the&amp;nbsp;nrfx_pwm_simple_playback() function.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/master/drivers/src/nrfx_pwm.c#L294"&gt;https://github.com/NordicSemiconductor/nrfx/blob/master/drivers/src/nrfx_pwm.c#L294&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I.e. set the loop register , and set the SHORT between LOOPSDONE and STOP&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>