<?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 Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72573/pwm-duty-cycle-measurement-spike</link><description>The servo I use in my application uses a PWM signal duty cycle to represent servo amperage level. 
 So, to measure servo amperage, I use a GPIOTE channel to capture the time between rising and falling edges of the servo&amp;#39;s PWM amperage signal. I then have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Mar 2021 14:52:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72573/pwm-duty-cycle-measurement-spike" /><item><title>RE: PWM Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/thread/299319?ContentTypeID=1</link><pubDate>Thu, 11 Mar 2021 14:52:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a471d31-dd21-4634-b5d1-0b75335367fe</guid><dc:creator>Ross Belloni</dc:creator><description>&lt;p&gt;Thanks Kenneth. I see the separate pin as the long term solution. We do have spare pins and when we will&amp;nbsp;do this in the future. In the mean time I put a logic test in place to look at the state of the pin on two toggles and only use the results if the states are different. You can close this thread and I very much appreciate your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/thread/299190?ContentTypeID=1</link><pubDate>Thu, 11 Mar 2021 09:30:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa772a22-f377-4204-9e47-bdedbed91681</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I was thinking the same problem, but you could possible connect the input to two pins? Presuming you have a spare gpio.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/thread/299124?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 20:26:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:902f118d-4deb-42ae-8738-8b383ba26d5f</guid><dc:creator>Ross Belloni</dc:creator><description>&lt;p&gt;I see this will not work since only one GPIOTE channel can be assigned to a physicl pin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/thread/299093?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 16:10:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a61e64c2-dcd1-4f1b-af49-7e1266dfb510</guid><dc:creator>Ross Belloni</dc:creator><description>&lt;p&gt;Thanks for the prompt reply.&lt;/p&gt;
&lt;p&gt;Suppose I set up an additional&amp;nbsp;GPIOTE channel that captures a timer value only the&amp;nbsp; rising edge of the servo amp signal.&amp;nbsp; Then in the interrupt handler I would&amp;nbsp; compare the timer capture from the rising edge only&amp;nbsp; to the timer capture from the rising and falling edge GPIOTE channel.&amp;nbsp; &amp;nbsp;If they were equal, then we would know we were about to measure the time between peaks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can i depend on the timer capture values to be equal assuming i was using the same timer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM Duty Cycle Measurement Spike</title><link>https://devzone.nordicsemi.com/thread/299023?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 13:53:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b39adc5-9b13-414b-b4a6-45c35085a4f4</guid><dc:creator>Kenneth</dc:creator><description>[quote user=""]Can I rely on the latch function instead of reading the pin to determine if I&amp;#39;m&amp;nbsp; measuring the width of the peak or the width of a valley?[/quote]
&lt;p&gt;As you already write: It may be that a toggle on a gpio port is so short, that by the time the interrupt is handled, then the pin have returned and thereby the actual source of the interrupt is not known.&amp;nbsp;This is a problem if the pin is setup with SENSE signal, in that case you can&amp;nbsp;read the&amp;nbsp;LATCH&amp;nbsp;register to find the actual&amp;nbsp;pin that caused the interrupt yes. You will not be able to measure how short (in time) the toggling was, but I guess that may not be a problem, since you don&amp;#39;t need very accurate precision (it&amp;#39;s enough to know it was shorter than a few tens of us since that is the time it took for the interrupt handler to be executed). You can find description of the LATCH register in the GPIO chapter:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpio.html#concept_zyt_tcb_lr"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/gpio.html#concept_zyt_tcb_lr&lt;/a&gt;&lt;/p&gt;
[quote user=""]Or alternatively, Can a I make a pin read and GPIOTE event via PPI?[/quote]
&lt;p&gt;I don&amp;#39;t see any good way to do this, typically you can for instance capture events on pin change (connected to a timer), but I don&amp;#39;t see any easy way for this pin to measure the length of the toggling (you would need to handle the interrupt between the two, and that is the problem in the first case).&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>