<?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>How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event</link><description>I am working on an application where I need to start pwm sequence after particular delay (accurate delay of multiple of 100us). 
 I am quite new to nordic environment. 
 Here is my code . Can please guide me what is wrong here??</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Jan 2022 10:28:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event" /><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/347122?ContentTypeID=1</link><pubDate>Tue, 11 Jan 2022 10:28:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4579ed16-3e90-4abd-978a-6e53dfce9c3c</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Ram&lt;br /&gt;&lt;br /&gt;I am now back in office again, thank you for your patience and well wishes for the holiday season!&lt;br /&gt;I hope you had a great holiday season as well! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I took a closer look at the video from the oscilloscope that you sent earlier, and I notice that this might just be drift from the HFCLK (which is 20 ppm) since it drifts for what approximately seems to be a total of 200 µs over 30 seconds, from what I could gather from the oscilloscope settings visible in the video. In that case, we should just need to synchronize the output PWM with the input PWM every so often, to avoid this being an issue.&lt;br /&gt;&lt;br /&gt;To synchronize them you could make use of the same mechanic as already implemented for the startup of the PWM: have the timer again started on an incoming flank, which in turn starts the waveform generation.&lt;br /&gt;Depending on how smooth the calibration/shift have to be (if it is acceptable to drop a couple of PWM periods or not, for example), there might have to be added some additional functionality for the restarting of the PWM waveform generation, or alternatively that another PWM instance is prepared, and it&amp;#39;s output is switched over to the phase-shifted PWM&amp;#39;s output when ready, for example. Could you give this a try - restarting the phase-shifted PWM waveform generation every so often - and see if it alleviates the issue?&lt;br /&gt;&lt;br /&gt;How often this synchronization will need to happen also depends on your application - how much drift is the maximum acceptable drift for your application?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/344874?ContentTypeID=1</link><pubDate>Thu, 23 Dec 2021 06:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61b0c633-eaff-46dc-a20d-6ffaa54dae37</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;&lt;span&gt;Hello again Karl,&lt;/span&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/344211#344211"]I regret to inform you that I unfortunately have been unable to properly look into and debug the project you provided me in your previous comment - I have been unavailable for some time now, and I will now be out of office until over new years.[/quote]
&lt;p&gt;No issue Karl, It will be really helpful if you look into the project after your vacation .&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Because for new tickets Its really slight hard for new person to get into the exact issue .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;I hope you will have a great holiday season, Karl !&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;&lt;span&gt;Best regards,&lt;br /&gt;Ram&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/344211?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 20:49:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf94102f-e3c7-4b9c-84d4-b24dc4cd56d2</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Ram,&lt;br /&gt;&lt;br /&gt;I regret to inform you that I unfortunately have been unable to properly look into and debug the project you provided me in your previous comment - I have been unavailable for some time now, and I will now be out of office until over new years.&lt;br /&gt;&lt;br /&gt;I still believe that the suggested PPI approach is the best fit for the application you have described, and so all that should remain is to pinpoint and resolve the reason for the added delay between the PWM periods.&lt;br /&gt;&lt;br /&gt;If you require support with this issue before I am back in office again I recommend that you open another ticket for this. Please know that the forum is operating on reduced staffing during the upcoming holiday season here in Norway, apologies for the inconvenience.&lt;br /&gt;&lt;br /&gt;I hope you will have a great holiday season, Ram!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/340280?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 09:38:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c304a55-1217-43a9-9bfb-259826327ce5</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello again , Karl&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Thank you for your support,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/340277#340277"]I too would think that this could become problematic later if you intend on having the device do additional things at equal or higher priority of the PWM generation.[/quote]
&lt;p&gt;Yeah, That&amp;#39;s why I persisted with your suggested way and hoping we could solve this issue very soon.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/340277#340277"]That is most peculiar. Could you send me an updated version of the project so I may take a look at this on my end?[/quote]
&lt;p&gt;Here I am attaching the updated project zip file for your reference.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/pwm_5F00_complementary_5F00_mode.zip"&gt;devzone.nordicsemi.com/.../pwm_5F00_complementary_5F00_mode.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/340277?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 09:18:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10a0ecf4-0767-4dc5-96bb-35ab09a9abf2</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Ram&lt;br /&gt;&lt;br /&gt;Thank you for your patience with this.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;Yes till now Its accurately periodic and well-behaved but till now CPU only handling GPIO , GPIO interrupt ,Timer and UART .&lt;/p&gt;
&lt;p&gt;It might be problematic later .&lt;/p&gt;[/quote]
&lt;p&gt;I too would think that this could become problematic later if you intend on having the device do additional things at equal or higher priority of the PWM generation.&lt;/p&gt;
[quote user="RAM_MS"]No ,after disabling also same shifting of waveform issue is there.[/quote]
&lt;p&gt;That is most peculiar. Could you send me an updated version of the project so I may take a look at this on my end?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/338122?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 10:33:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:893d161c-7b30-4fc2-890b-40b501509c38</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/338095#338095"]It will depend on your applications requirements and constraints. For example, how detrimental is it that the waveform is accurately periodic and well-behaved?[/quote]
&lt;p&gt;Yes till now Its accurately periodic and well-behaved but till now CPU only handling GPIO , GPIO interrupt ,Timer and UART .&lt;/p&gt;
&lt;p&gt;It might be problematic later .&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/338095#338095"]Do you see any difference to the behavior of the waveform when you disable the peripherals?[/quote]
&lt;p&gt;No ,after disabling also same shifting of waveform issue is there.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/338095?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 09:51:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3c4027c-f82d-4348-9c25-7d83fa7241cf</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Ram&lt;/p&gt;
[quote user="RAM_MS"]Actually I just want to discuss same ,is this approach is ok?[/quote]
&lt;p&gt;It will depend on your applications requirements and constraints. For example, how detrimental is it that the waveform is accurately periodic and well-behaved?&lt;br /&gt;If you use the CPU to generate the waveform and you have other things happening in your program with equal or higher priority you will never be able to guarantee a correct waveform with the CPU approach, which is why this often is not a viable method for waveform generation.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;At the same time I am trying the method what we discussed yet and given you the tested result but you didn&amp;#39;t reply that.&lt;/p&gt;
&lt;p&gt;Please reply on that also.&lt;/p&gt;[/quote]
&lt;p&gt;Oh, I thought your previous comment meant that you had moved on from that approach.&lt;br /&gt;&lt;br /&gt;Do you see any difference to the behavior of the waveform when you disable the peripherals?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/338057?ContentTypeID=1</link><pubDate>Tue, 09 Nov 2021 07:32:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47f275fe-d692-41dd-8cec-bd31ffad9ce2</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/337691#337691"]The big difference between the implementation you have made for the other µC and the one we have been working on is that the one for the other µC uses the CPU to set and clear the GPIO.&lt;br /&gt;This is not a viable approach for a larger project - since you will not have any guarantees that the CPU will not be busy in a higher / equal priority interrupt, which will delay the set/clear&amp;nbsp;execution and lead to a incorrect waveform.[/quote]
&lt;p&gt;Actually I just want to discuss same ,is this approach is ok?&lt;/p&gt;
&lt;p&gt;At the same time I am trying the method what we discussed yet and given you the tested result but you didn&amp;#39;t reply that.&lt;/p&gt;
&lt;p&gt;Please reply on that also.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/337691?ContentTypeID=1</link><pubDate>Fri, 05 Nov 2021 12:49:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce6d4cdb-f9b1-4f26-9d68-7c22c7ca3f18</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again, Ram&lt;/p&gt;
[quote user="RAM_MS"] I am implemented a new logic with a different controller and its working properly .[/quote][quote user="RAM_MS"]So Karl Please guide to implement&amp;nbsp; these steps in &lt;strong&gt;NORDIC&lt;/strong&gt;&amp;nbsp;.[/quote]
&lt;p&gt;The big difference between the implementation you have made for the other µC and the one we have been working on is that the one for the other µC uses the CPU to set and clear the GPIO.&lt;br /&gt;This is not a viable approach for a larger project - since you will not have any guarantees that the CPU will not be busy in a higher / equal priority interrupt, which will delay the set/clear&amp;nbsp;execution and lead to a incorrect waveform.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve attached an example that shows how what you describe can be done. A toggle on the PIN_IN starts a timer&amp;nbsp;that repeatedly toggles the PIN_OUT at a given interval. If you would like the start delay and pulse length to be different you will need to add another timer instance to implement the start delay, and then have it start the toggle timer upon expiring.&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/_5F005F00_delayed_5F00_gpiote_5F00_toggle.zip"&gt;devzone.nordicsemi.com/.../_5F005F00_delayed_5F00_gpiote_5F00_toggle.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/337077?ContentTypeID=1</link><pubDate>Tue, 02 Nov 2021 12:18:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc9bb191-3cf4-4f0a-97b6-356bcaf32c7d</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I am implemented a new logic with a different controller and its working properly .&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;And its very small code also using only &lt;strong&gt;external interrupt&lt;/strong&gt; ,&lt;strong&gt;Timer&lt;/strong&gt; (in one shot mode)and &lt;strong&gt;GPIO&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/strong&gt;without &lt;strong&gt;PWM&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I am attaching that for your reference .&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void EINT024_IRQHandler(void)
{
    /* To check if PA.6 external interrupt occurred */
    if(GPIO_GET_INT_FLAG(PA, BIT6))
    {
			  
              GPIO_CLR_INT_FLAG(PA, BIT6);
			  flg_Start_PWM=1;
			  TIMER_SET_CMP_VALUE(TIMER0, delay);
			  TIMER_Start(TIMER0);	
		}
   
}

void TMR0_IRQHandler(void)
{
    if(TIMER_GetIntFlag(TIMER0) == 1)
    {
			  if(PA6 == 1) // Checking either rising edge or falling
			 {
				/* Clear Timer0 time-out interrupt flag */
        TIMER_ClearIntFlag(TIMER0);
				
				PB5=1;
				PB4=0;
				
	     }
			 else    //logic for falling edge
				{
					/* Clear Timer0 time-out interrupt flag */
          TIMER_ClearIntFlag(TIMER0);
					
					PB5=0;
				    PB4=1;
			    
					
				}      
    }
            
 }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Explanation for details.&lt;/p&gt;
&lt;p&gt;1)Enabled&lt;strong&gt; External Interrupt pin&lt;/strong&gt; For &lt;strong&gt;both edge for INPUTTED PWM Signal.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;2) Then start &lt;strong&gt;Timer&lt;/strong&gt; in Both Edge in&amp;nbsp;&lt;strong&gt;ONE SHOT MODE.&lt;/strong&gt;(That&amp;#39;s why I loaded Compare value every time)&lt;/p&gt;
&lt;p&gt;3)Then in &lt;strong&gt;TMR_INTERRUPT HANDLER&amp;nbsp;&lt;/strong&gt;handle the&amp;nbsp;&lt;strong&gt;GPIO&amp;nbsp;&lt;/strong&gt;as per required.&lt;/p&gt;
&lt;p&gt;4) And Finally Tested with external &lt;strong&gt;INPUTTED PWM SIGNAL&lt;/strong&gt;&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;I am attaching video of that for your reference .&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/20211102_5F00_173942.mp4"&gt;devzone.nordicsemi.com/.../20211102_5F00_173942.mp4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So Karl Please guide to implement&amp;nbsp; these steps in &lt;strong&gt;NORDIC&lt;/strong&gt;&amp;nbsp;.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/337047?ContentTypeID=1</link><pubDate>Tue, 02 Nov 2021 10:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bce54fc-a557-4f13-90a2-142f99c45fe3</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/337039#337039"]Please check for the&amp;nbsp;&lt;a title="NRFX_PWM_EVT_END_SEQ0" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__pwm.html?cp=8_1_6_8_0_24_1_8_1#gga3bd252a13f482085e89e23516b8a422aa9548867c6bb75600cd7fb219b868fe30"&gt;NRFX_PWM_EVT_END_SEQ0&lt;/a&gt;&amp;nbsp;event in your pwm_handler.&lt;br /&gt;The PWM HAL event NRF_PWM_EVENT_SEQEND0 is only ever used by the nrfx driver behind the scenes, and not actually ever forwarded to the application layer event handler. If the NRF_PWM_EVENT_SEQEND0 event is generated by the PWM peripheral, the nrfx driver will forward&amp;nbsp;&lt;a title="NRFX_PWM_EVT_END_SEQ0" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__pwm.html?cp=8_1_6_8_0_24_1_8_1#gga3bd252a13f482085e89e23516b8a422aa9548867c6bb75600cd7fb219b868fe30"&gt;NRFX_PWM_EVT_END_SEQ0&lt;/a&gt;&amp;nbsp;to the application layer.[/quote]
&lt;p&gt;&lt;strong&gt;NRFX_PWM_EVT_END_SEQ0&lt;/strong&gt; is not returned instead&amp;nbsp;&lt;strong&gt;NRFX_PWM_EVT_FINISHED&amp;nbsp;&lt;/strong&gt;is returning.&lt;/p&gt;
&lt;p&gt;So I edited program like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void disable_pwm_startup_peripherals()
{
 nrf_drv_gpiote_in_event_disable(PIN_IN);
 nrf_drv_ppi_channel_disable(ppi_channel_1);
 nrfx_timer_disable(&amp;amp;PWM_DELAY_TIMER);
 nrf_drv_ppi_channel_disable(ppi_channel_2);

}

static void irq_handler(nrfx_pwm_evt_type_t event_type)
{
 
 switch(event_type)
 {
   case NRFX_PWM_EVT_FINISHED:
        NRF_LOG_INFO(&amp;quot;PWM IS STARTED&amp;quot;);
        disable_pwm_startup_peripherals();
        break;
   default:
   // nothing
        break;
 }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But this also not solving the issue .&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/337039?ContentTypeID=1</link><pubDate>Tue, 02 Nov 2021 10:30:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aefe9aa-011c-41ef-9678-828ae1a381de</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="RAM_MS"]No issue Karl,&amp;nbsp; I am really happy with your support and I really positively hoping&amp;nbsp; that we are going to solve this very soon.[/quote]
&lt;p&gt;I am happy to you that, Ram!&lt;br /&gt;I too hope we will resolve this last issue soon.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;First I didn&amp;#39;t understand how SEQEND0 will return because sequence is going on .&lt;/p&gt;
&lt;p&gt;But still I tried with&amp;nbsp;&lt;strong&gt;case NRF_PWM_EVENT_SEQEND0:&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;in the place of&amp;nbsp;&amp;nbsp;&lt;strong&gt;case NRF_PWM_EVENT_SEQSTARTED0:&amp;nbsp;&lt;/strong&gt;. But in debug the cursor isn&amp;#39;t coming as&amp;nbsp;&amp;nbsp;&lt;strong&gt;event_type&amp;nbsp;&lt;/strong&gt;return 0x0000 value.&lt;/p&gt;
&lt;p&gt;Maybe some where initialization is not happening correctly or some other reason.&lt;/p&gt;[/quote]
&lt;p&gt;Oh, I should have been more explicit again, my apologies.&lt;br /&gt;Please check for the&amp;nbsp;&lt;a title="NRFX_PWM_EVT_END_SEQ0" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__pwm.html?cp=8_1_6_8_0_24_1_8_1#gga3bd252a13f482085e89e23516b8a422aa9548867c6bb75600cd7fb219b868fe30"&gt;NRFX_PWM_EVT_END_SEQ0&lt;/a&gt;&amp;nbsp;event in your pwm_handler.&lt;br /&gt;The PWM HAL event NRF_PWM_EVENT_SEQEND0 is only ever used by the nrfx driver behind the scenes, and not actually ever forwarded to the application layer event handler. If the NRF_PWM_EVENT_SEQEND0 event is generated by the PWM peripheral, the nrfx driver will forward&amp;nbsp;&lt;a title="NRFX_PWM_EVT_END_SEQ0" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__pwm.html?cp=8_1_6_8_0_24_1_8_1#gga3bd252a13f482085e89e23516b8a422aa9548867c6bb75600cd7fb219b868fe30"&gt;NRFX_PWM_EVT_END_SEQ0&lt;/a&gt;&amp;nbsp;to the application layer.&lt;br /&gt;&lt;br /&gt;If my understanding of the end event is correct then the end event will be generated whenever the section has been played once, before it loops.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void pwm_handler(nrf_pwm_event_t event_type)
{
    switch(event_type)
    {
        case NRFX_PWM_EVT_END_SEQ0:
            NRF_LOG_INFO(&amp;quot;PWM IS STARTED&amp;quot;);
            disable_pwm_startup_peripherals();
            break;
        default:
            // nothing
            break;
    }
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Alternatively, you could for debugging&amp;#39;s sake add the following to the nrfx_pwm.c irq_handler function:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;..
    if (nrf_pwm_event_check(p_pwm, NRF_PWM_EVENT_EVENTS_SEQSTARTED0))
    {
        nrf_pwm_event_clear(p_pwm, NRF_PWM_EVENT_EVENTS_SEQSTARTED0);

        p_cb-&amp;gt;handler(NRFX_PWM_EVT_STARTED_SEQ0);
    }
..&lt;/pre&gt;&lt;br /&gt;But since &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrfx__pwm.html#ga3bd252a13f482085e89e23516b8a422a"&gt;the nrfx_pwm driver does not have a dedicated started event&lt;/a&gt;&amp;nbsp;we will also have to add the following modification into nrfx_pwm.h:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;..
/** @brief PWM driver event type. */
typedef enum
{
    NRFX_PWM_EVT_FINISHED, ///&amp;lt; Sequence playback finished.
    NRFX_PWM_EVT_END_SEQ0, /**&amp;lt; End of sequence 0 reached. Its data can be
                                safely modified now. */
    NRFX_PWM_EVT_END_SEQ1, /**&amp;lt; End of sequence 1 reached. Its data can be
                                safely modified now. */
    NRFX_PWM_EVT_STOPPED,  ///&amp;lt; The PWM peripheral has been stopped.
    NRFX_PWM_EVT_STARTED_SEQ0,  ///&amp;lt; Sequence 0 has started.
} nrfx_pwm_evt_type_t;
..&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;In general it is recommended to avoid modifying the provided drivers directly, since this may break them or place them into invalid states, but I list it here as an alternative approach nevertheless, since we are in the process of debugging the issue of the growing phase shift of the outputted PWM.&lt;br /&gt;Keep in mind that this driver modification will make the started event be sent to your application layer frequently, so you should add a check in the pwm_handler so that it only disables the peripherals the first time it is generated.&lt;/p&gt;
&lt;p&gt;The important part here is that we get to test if the disabling of the startup peripherals will resolve the phase shifting issue of the output PWM.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336966?ContentTypeID=1</link><pubDate>Tue, 02 Nov 2021 05:40:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:228d84fb-d36f-4ed9-8a3b-e1be4f6675da</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336919#336919"]You could either edit the driver to pass the STARTED event to the application layer, or use the SEQEND0 event instead. I would recommend the latter, since it comes with lower risk (modifying a driver is always a potential way to break it), and since using the SEQEND event instead should be fine in this case - we only need to know that the PWM has successfully started in order to disable the startup peripherals.[/quote]
&lt;p&gt;First I didn&amp;#39;t understand how SEQEND0 will return because sequence is going on .&lt;/p&gt;
&lt;p&gt;But still I tried with&amp;nbsp;&lt;strong&gt;case NRF_PWM_EVENT_SEQEND0:&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;&lt;/strong&gt;in the place of&amp;nbsp;&amp;nbsp;&lt;strong&gt;case NRF_PWM_EVENT_SEQSTARTED0:&amp;nbsp;&lt;/strong&gt;. But in debug the cursor isn&amp;#39;t coming as&amp;nbsp;&amp;nbsp;&lt;strong&gt;event_type&amp;nbsp;&lt;/strong&gt;return 0x0000 value.&lt;/p&gt;
&lt;p&gt;Maybe some where initialization is not happening correctly or some other reason.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336919#336919"]Apologies for the inconvenience. Could you try this, and let me know if this resolves the compounded delay issue?[/quote]
&lt;p&gt;No issue Karl,&amp;nbsp; I am really happy with your support and I really positively hoping&amp;nbsp; that we are going to solve this very soon.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336919?ContentTypeID=1</link><pubDate>Mon, 01 Nov 2021 16:01:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf78dfb9-8f23-453e-80a2-2702eda5df1d</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Ram,&lt;br /&gt;&lt;br /&gt;It looks like you are doing it correct in your code, so I was surprised that this did not work. I looked into the nrfx_pwm driver, which is what is being called behind the scenes of the nrf_drv_pwm_init call, and &lt;a href="https://github.com/NordicSemiconductor/nrfx/blob/v1.8.6/drivers/src/nrfx_pwm.c#L422"&gt;it seems that it does not forward the _SEQSTARTED0 event after all&lt;/a&gt;, my mistake.&lt;br /&gt;You could either edit the driver to pass the STARTED event to the application layer, or use the SEQEND0 event instead. I would recommend the latter, since it comes with lower risk (modifying a driver is always a potential way to break it), and since using the SEQEND event instead should be fine in this case - we only need to know that the PWM has successfully started in order to disable the startup peripherals.&lt;br /&gt;Apologies for the inconvenience. Could you try this, and let me know if this resolves the compounded delay issue?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336749?ContentTypeID=1</link><pubDate>Sat, 30 Oct 2021 10:31:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f85c6164-1f1e-45b2-9d81-40cef41766d4</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336705#336705"]You could check that the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pwm.html?cp=4_0_0_5_16_4_4#register.EVENTS_SEQSTARTED-0-1"&gt;EVENTS_SEQSTARTED[n]&lt;/a&gt;&amp;nbsp;event happens. This will indicate that the sequence has started.&lt;br /&gt;You can add this event as a case in the pwm handler, and then either add a breakpoint or a logger statement to indicate that the event is generated as expected.[/quote]
&lt;p&gt;I created as you told please verify it ,is it right ?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void pwm_handler(nrf_pwm_event_t event_type)
{
 switch(event_type)
 {
   case NRF_PWM_EVENT_SEQSTARTED0:
        NRF_LOG_INFO(&amp;quot;PWM IS STARTED&amp;quot;);
        break;
   default:
   // nothing
        break;
 }
}

APP_ERROR_CHECK(nrf_drv_pwm_init(&amp;amp;m_pwm0, &amp;amp;config0, pwm_handler));&lt;/pre&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Because after adding this code , I tested with debug breakpoint but it never come true that is cursor goes to default never stop in case&amp;nbsp;&lt;strong&gt;NRF_PWM_EVENT_SEQSTARTED0&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336705?ContentTypeID=1</link><pubDate>Fri, 29 Oct 2021 13:57:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a37d65e-71db-480d-bb14-a069e919f82f</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Ram,&lt;/p&gt;
[quote user="RAM_MS"]Yes ,actually that was just a by mistake . I made it proper.[/quote]
&lt;p&gt;Great - it is no problem at all, I just thought I should mention it since I noticed.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;How to check if PWM is successfully started ?&lt;/p&gt;
&lt;p&gt;Is there any function in SDK which return this ?&lt;/p&gt;
&lt;p&gt;Because I checked with return value from &lt;strong&gt;pwm_init () which is NRF_SUCCESS.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But this is not right way may be .&lt;/p&gt;
&lt;p&gt;So can you please guide me here.&lt;/p&gt;[/quote]
&lt;p&gt;You could check that the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/pwm.html?cp=4_0_0_5_16_4_4#register.EVENTS_SEQSTARTED-0-1"&gt;EVENTS_SEQSTARTED[n]&lt;/a&gt;&amp;nbsp;event happens. This will indicate that the sequence has started.&lt;br /&gt;You can add this event as a case in the pwm handler, and then either add a breakpoint or a logger statement to indicate that the event is generated as expected.&lt;br /&gt;You could use this event to indicate that the PWM is successfully running, so that you may disable the GPIOTE, TIMER and PPI channels used to set it up.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336586?ContentTypeID=1</link><pubDate>Fri, 29 Oct 2021 06:34:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a8ec5a8-ec47-4a37-b56b-97af5f79ceb8</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336520#336520"]By the way, you can change your&amp;nbsp;&lt;span&gt;GPIOTE_CONFIG_IN_SENSE_LOTOHI&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;true&lt;/span&gt;&lt;span&gt;); back to false again - since this was not the cause of the added delay earlier.&lt;/span&gt;[/quote]
&lt;p&gt;Yes ,I did that.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336520#336520"]I also notice that you are still not using the pwm start task address returned from the nrf_drv_pwm_simple_playback call, since it is overwritten by the call to nrf_pwm_task_addr_get in the ppi_init - this should not matter though, since they should point to the same address - but I point it out to avoid any confusion since you have stated earlier that it is this return address that is being used.[/quote]
&lt;p&gt;Yes ,actually that was just a by mistake . I made it proper.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336520#336520"]I do not immediately see the reason for why the phase shift would be happening, but I suspect that it might be because the PPI channels are left enabled throughout the run of the application, so that there might be happening a brief stopping and re-starting of the waveform generation, or similar, causing the phase shift.&lt;br /&gt;Could you try to implement the stopping / disabling of the GPIOTE pin, TIMER instance and PPI channels when the PWM is successfully started, like we talked about earlier?[/quote]
&lt;p&gt;How to check if PWM is successfully started ?&lt;/p&gt;
&lt;p&gt;Is there any function in SDK which return this ?&lt;/p&gt;
&lt;p&gt;Because I checked with return value from &lt;strong&gt;pwm_init () which is NRF_SUCCESS.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But this is not right way may be .&lt;/p&gt;
&lt;p&gt;So can you please guide me here.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336520?ContentTypeID=1</link><pubDate>Thu, 28 Oct 2021 14:06:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0adb0b78-289d-46d7-8da2-e9d9b5a3088e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="RAM_MS"]&lt;p&gt;I am really happy that we patiently progress up to this stage.&lt;/p&gt;
&lt;p&gt;And Thank you a lot .&lt;/p&gt;[/quote]
&lt;p&gt;No problem at all, Ram - I am happy to help!&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;As earlier I said for testing purpose I generated 1st in the same DK in PWM_PIN(11).&lt;/p&gt;
&lt;p&gt;But for now I commented this part by commenting&amp;nbsp;&lt;strong&gt;pwm1_init();&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And giving INPUTTED PWM Signal from Different DK in PIN_IN (22);&lt;/p&gt;[/quote]
&lt;p&gt;Thank you for clarifying this.&lt;/p&gt;
[quote user="RAM_MS"]For your reference I am attaching code here.[/quote]
&lt;p&gt;I do not immediately see the reason for why the phase shift would be happening, but I suspect that it might be because the PPI channels are left enabled throughout the run of the application, so that there might be happening a brief stopping and re-starting of the waveform generation, or similar, causing the phase shift.&lt;br /&gt;Could you try to implement the stopping / disabling of the GPIOTE pin, TIMER instance and PPI channels when the PWM is successfully started, like we talked about earlier?&lt;br /&gt;&lt;br /&gt;By the way, you can change your&amp;nbsp;&lt;span&gt;GPIOTE_CONFIG_IN_SENSE_LOTOHI&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;true&lt;/span&gt;&lt;span&gt;); back to false again - since this was not the cause of the added delay earlier.&lt;br /&gt;&lt;br /&gt;I also notice that you are still not using the pwm start task address returned from the nrf_drv_pwm_simple_playback call, since it is overwritten by the call to nrf_pwm_task_addr_get in the ppi_init - this should not matter though, since they should point to the same address - but I point it out to avoid any confusion since you have stated earlier that it is this return address that is being used.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336491?ContentTypeID=1</link><pubDate>Thu, 28 Oct 2021 13:02:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b7037cb-61b6-43b5-9d74-b93566608ced</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336478#336478"]I am happy to hear that this resolved the added delay issue![/quote]
&lt;p&gt;I am really happy that we patiently progress up to this stage.&lt;/p&gt;
&lt;p&gt;And Thank you a lot .&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336478#336478"]That is very strange indeed. Perhaps there is something amiss with the sequence looping.&lt;br /&gt; &lt;br /&gt;Could you&amp;nbsp;share the newest&amp;nbsp;version of the code - the code you ran when you observed this - so I may see if I can spot any potential explanation for this?[/quote]
&lt;p&gt;For your reference I am attaching code here.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/7384.main.zip"&gt;devzone.nordicsemi.com/.../7384.main.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;As earlier I said for testing purpose I generated 1st in the same DK in PWM_PIN(11).&lt;/p&gt;
&lt;p&gt;But for now I commented this part by commenting&amp;nbsp;&lt;strong&gt;pwm1_init();&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And giving INPUTTED PWM Signal from Different DK in PIN_IN (22);&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336478?ContentTypeID=1</link><pubDate>Thu, 28 Oct 2021 12:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4214c14f-1e8e-4f05-9150-8353ee79aefe</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
[quote user="RAM_MS"]Thank you so much Karl ,this was the problem in my code after arranging this correcting now I am able to get exact TIMING Delay .[/quote]
&lt;p&gt;No problem at all, Ram - I am happy to hear that this resolved the added delay issue!&lt;/p&gt;
[quote user="RAM_MS"]Sorry ,You are right I shared the code that was used to test the TIMER&amp;#39;s accuracy.[/quote][quote user="RAM_MS"]Yes ,you are right I am using that variable to store it and pass it to the PPI assign function.[/quote][quote user="RAM_MS"]As always Yellow one is INPUTTED PWM SIGNAL and Blue one is my OUTPUT PWM .[/quote]
&lt;p&gt;Thank you for clarifying these things.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;For testing purpose I generated inputting PWM signal from PIN NO 11( that is PWM_PIN 11) in the code you might seen it and giving it to (PIN_IN 22).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But in real case the inputting PWM will come from outside .&lt;/p&gt;
&lt;p&gt;So for create this scenario I created inputted PWM signal from a different NRF52 DK .&lt;/p&gt;
&lt;p&gt;And what I observed is my Generated PWM Signal is Shifting with time.&lt;/p&gt;
&lt;p&gt;For your reference I am attaching the video of it.&lt;/p&gt;[/quote]
&lt;p&gt;That is very strange indeed. Perhaps there is something amiss with the sequence looping.&lt;br /&gt; &lt;br /&gt;Could you&amp;nbsp;share the newest&amp;nbsp;version of the code - the code you ran when you observed this - so I may see if I can spot any potential explanation for this?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336205?ContentTypeID=1</link><pubDate>Wed, 27 Oct 2021 12:31:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d2ee952-924f-4d41-8684-39f4fc33f6a6</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336040#336040"]I do not see this change implemented in the code you just shared - it seems like this might be the code that was used to test the TIMER&amp;#39;s accuracy.[/quote]
&lt;p&gt;Sorry ,You are right I shared the code that was used to test the TIMER&amp;#39;s accuracy.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336040#336040"]I see that you have created a global variable to store the pwm_task_addr returned by the nrf_drv_pwm_simple_playback function call, so I assume you will be using that variable to store it, and pass it to the PPI assign function.[/quote]
&lt;p&gt;Yes ,you are right I am using that variable to store it and pass it to the PPI assign function.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/336040#336040"]You will also need to run the GPIOTE and PWM init functions before the PPI init function, to make sure that the addresses has been updated before they are connected through the PPI.[/quote]
&lt;p&gt;Thank you so much Karl ,this was the problem in my code after arranging this correcting now I am able to get exact TIMING Delay .&lt;/p&gt;
&lt;p&gt;Now ,another problem arises actually .&lt;/p&gt;
&lt;p&gt;For testing purpose I generated inputting PWM signal from PIN NO 11( that is PWM_PIN 11) in the code you might seen it and giving it to (PIN_IN 22).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But in real case the inputting PWM will come from outside .&lt;/p&gt;
&lt;p&gt;So for create this scenario I created inputted PWM signal from a different NRF52 DK .&lt;/p&gt;
&lt;p&gt;And what I observed is my Generated PWM Signal is Shifting with time.&lt;/p&gt;
&lt;p&gt;For your reference I am attaching the video of it.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/20211027_5F00_174841.mp4"&gt;devzone.nordicsemi.com/.../20211027_5F00_174841.mp4&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;what could be the reason for this problem ?&lt;/p&gt;
&lt;p&gt;As always Yellow one is INPUTTED PWM SIGNAL and Blue one is my OUTPUT PWM .&lt;/p&gt;
&lt;p&gt;And you can clearly see that blue line is slowly shifting to left .&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/336040?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 15:23:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a8b9d06-8769-4406-b63c-e03dcc6918ff</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="RAM_MS"]Here I attached the code for your reference.[/quote]
&lt;p&gt;Thank you for sharing the code.&lt;br /&gt;Looking through the code I notice that you are initializing the GPIOTE as a low-accuracy input, in the line:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);&lt;/pre&gt;&lt;br /&gt;Could you try to change this to high accuracy, by changing the configuration parameter to &lt;em&gt;true&lt;/em&gt;?&lt;br /&gt;I do not really think that this should matter, since the PORT event will be triggered just as fast as the IN_EVENT, but it would be good to have ruled out as well.&lt;br /&gt;&lt;br /&gt;I also recommend that you define your pins using the NRF_GPIO_PIN_MAP macro instead of just writing their pin number, but this is a very minor comment on my part and it will work just as well with the pins number directly.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;Yes ,I changed .&lt;/p&gt;
&lt;p&gt;Please verify once is it right in provided code.&lt;/p&gt;[/quote]
&lt;p&gt;I do not see this change implemented in the code you just shared - it seems like this might be the code that was used to test the TIMER&amp;#39;s accuracy.&lt;br /&gt;I see that you have created a global variable to store the pwm_task_addr returned by the nrf_drv_pwm_simple_playback function call, so I assume you will be using that variable to store it, and pass it to the PPI assign function.&lt;br /&gt;I would urge you to add a check to the PPI init function that checks if the pwm_task_addr and gpiote_task_addr variables has been set before you proceed to pass them to the PPI peripheral.&lt;br /&gt;You will also need to run the GPIOTE and PWM init functions before the PPI init function, to make sure that the addresses has been updated before they are connected through the PPI.&lt;/p&gt;
[quote user="RAM_MS"]I am trying to test this .I will update you soon.[/quote]
&lt;p&gt;Great, I look forward to hearing what you find out! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/335845?ContentTypeID=1</link><pubDate>Tue, 26 Oct 2021 05:19:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:959bfddb-8353-4b30-b404-aea66f1a6b2e</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335800#335800"]Could you show me your code as it is right now? I will take a look and see if I can spot what might be adding the delay.[/quote]
&lt;p&gt;Here I attached the code for your reference.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0310.main.zip"&gt;devzone.nordicsemi.com/.../0310.main.zip&lt;/a&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335800#335800"]Did you change it so that you are providing the pwm_start_task_address returned from the nrf_drv_simple_playback call to the PPI initialization?[/quote]
&lt;p&gt;Yes ,I changed .&lt;/p&gt;
&lt;p&gt;Please verify once is it right in provided code.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335800#335800"]Could you check whether you are receiving any&amp;nbsp;&lt;span&gt;EVENTS_SEQSTARTED events in your pwm event handler?&lt;br /&gt;&lt;/span&gt;To find out how long it takes from the PWM start task is triggered until the SEQSTARTED event is received you could use the&amp;nbsp;&lt;a title="nrf_timer_cc_read" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrf__timer__hal.html?cp=8_1_6_8_0_37_2_15#ga815d0de9eea067c0c3a2ee622eee3958"&gt;nrf_timer_cc_read&lt;/a&gt;&amp;nbsp;function in the timer&amp;#39;s event handler for the CC event, and then again in the PWM handler for the&amp;nbsp;&lt;span&gt;SEQSTARTED&amp;nbsp;event - then subtract the initial value and the added delay to find the difference.&lt;/span&gt;&lt;br /&gt;[/quote]
&lt;p&gt;I am trying to test this .I will update you soon.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;br /&gt;&lt;span&gt;Ram&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/335800?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 14:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:693eddb4-c792-4075-93cb-2ac042b52ecc</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Ram,&lt;br /&gt;&lt;br /&gt;Thank you for the clarification and update.&lt;/p&gt;
[quote user="RAM_MS"]&lt;p&gt;I tested with different delays that is 1ms ,2ms ,3ms etc .Every where the same added delay around 200&amp;nbsp;&lt;span&gt;µs&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;coming.&lt;/p&gt;[/quote][quote user="RAM_MS"]I tested this and the output is attached here in below .[/quote][quote user="RAM_MS"]&lt;p&gt;Here yellow line is &lt;span&gt;inputted PWM and blue line is gpio toggle output .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here you can clearly notice that 2ms timing is exact.&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;This is great steps for the debugging - well done!&lt;br /&gt;So, it it clear that the timer toggles the GPIOTE at a precise interval, and that the delay is added elsewhere.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Could you check whether you are receiving any&amp;nbsp;&lt;span&gt;EVENTS_SEQSTARTED events in your pwm event handler?&lt;br /&gt;&lt;/span&gt;To find out how long it takes from the PWM start task is triggered until the SEQSTARTED event is received you could use the&amp;nbsp;&lt;a title="nrf_timer_cc_read" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrf__timer__hal.html?cp=8_1_6_8_0_37_2_15#ga815d0de9eea067c0c3a2ee622eee3958"&gt;nrf_timer_cc_read&lt;/a&gt;&amp;nbsp;function in the timer&amp;#39;s event handler for the CC event, and then again in the PWM handler for the&amp;nbsp;&lt;span&gt;SEQSTARTED&amp;nbsp;event - then subtract the initial value and the added delay to find the difference.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Could you show me your code as it is right now? I will take a look and see if I can spot what might be adding the delay.&lt;br /&gt;Did you change it so that you are providing the pwm_start_task_address returned from the nrf_drv_simple_playback call to the PPI initialization?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to start pwm sequence after particular time delay of gpio event?</title><link>https://devzone.nordicsemi.com/thread/335630?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 06:58:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffe6eac6-8fdd-4c7d-b413-1736df6d81f2</guid><dc:creator>RAM_MS</dc:creator><description>&lt;p&gt;Hello Karl,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335597#335597"]This does indeed not look correct - that is quite the added delay, more than 200 µs it seems.&lt;br /&gt;Could you clarify exactly what you are scoping here with the blue and yellow line? I assume it is the inputted PWM and the resulting delayed PWM output, but it would be good if you could confirm / specify this[/quote]
&lt;p&gt;Yes ,you assumed right .Yellow line is inputted PWM and blue line is delayed PWM output.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335597#335597"]To debug this we will need to find out where in the chain of events this delay is introduced.&lt;br /&gt;Could you try this again with different delays, so we may see if there is an issue with the timer configuration for instance?[/quote]
&lt;p&gt;I tested with different delays that is 1ms ,2ms ,3ms etc .Every where the same added delay around 200&amp;nbsp;&lt;span&gt;&amp;micro;s&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;coming.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/79976/how-to-start-pwm-sequence-after-particular-time-delay-of-gpio-event/335597#335597"]Alternatively, as a debugging measure, you could change to have the TIMER CC event connected to a pin toggle TASK, so we may verify that the timer is producing the correct delay.[/quote]
&lt;p&gt;I tested this and the output is attached here in below .&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/IMG_5F00_20211025_5F00_123836.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;Here yellow line is &lt;span&gt;inputted PWM and blue line is gpio toggle output .&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Here you can clearly notice that 2ms timing is exact.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Ram&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>