<?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>Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67368/toggle-2-leds-back-and-forth-with-ppi-gpiote-and-timer</link><description>Hello, 
 
 I am using NRF52840 DK to toggle led 3 and 4 back and forth (when LED 3 is ON, LED 4 should be OFF and so on). I have to toggle them in a small time interval of 10ms. I am using SDK 17.02. In order for the power consumption I am using GPIOTE</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Oct 2020 09:53:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67368/toggle-2-leds-back-and-forth-with-ppi-gpiote-and-timer" /><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/277322?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 09:53:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95ffb1f3-d2e3-4c33-a14d-a029549c08b1</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for that detailed discription. Yes I was trying to use different task for setting and clearing pins.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
&lt;p&gt;Adarsh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/277301?ContentTypeID=1</link><pubDate>Wed, 28 Oct 2020 08:57:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b431a6b-0a1c-4a9d-9f7b-d8f9d01679d9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;First of all you should be careful when you call APP_ERROR_CHECK(err_code) on an err_code that has not received a value, like you do in led_blinking_setup(), right after the lines:&lt;/p&gt;
&lt;p&gt;nrf_ppi_channel_t ppi_channel;&lt;/p&gt;
&lt;p&gt;and&lt;/p&gt;
&lt;p&gt;nrf_ppi_channel_t ppi_channel1;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am not sure exactly what you have been trying to do. Did you intend to use:&lt;/p&gt;
&lt;p&gt;nrf_drv_gpiote_out_config_t config1 = GPIOTE_CONFIG_OUT_TASK_HIGH;&lt;br /&gt;nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_LOW;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Remember that one of them will set the pin low, and the other will set the pin high.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;another thing:&lt;/p&gt;
&lt;p&gt;nrf_drv_timer_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, (ticks_RED/2), true);&lt;br /&gt;nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL1, ticks_RED, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You set CC0 shorter than CC1, and you reset the timer on CC0 (Compare0_clear_mask). Change it to NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, if you want the timer to count to reach CC1 = ticks_RED.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Check out these two modified implementations:&lt;/p&gt;
&lt;p&gt;using 2 PPI channels:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void led_blinking_setup()
{
    uint32_t compare_evt_addr;
    uint32_t gpiote_task_addr;
    uint32_t compare_evt_addr1;
    uint32_t gpiote_task_addr1;
    uint32_t err_code;
   
    nrf_ppi_channel_t ppi_channel;
    //APP_ERROR_CHECK(err_code);

    nrf_ppi_channel_t ppi_channel1;
    //APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_config_t config1 = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
    nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
    //nrf_drv_gpiote_out_config_t config1 = GPIOTE_CONFIG_OUT_TASK_HIGH;
    //nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_LOW;

   err_code = nrfx_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER, &amp;amp;config1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER2, &amp;amp;config2);
    APP_ERROR_CHECK(err_code);

    uint32_t ticks_RED = nrfx_timer_ms_to_ticks(&amp;amp;timer, 200);

    nrf_drv_timer_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, (ticks_RED/2), true);
    nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL1, ticks_RED, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel1);
    APP_ERROR_CHECK(err_code);
 
    compare_evt_addr = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE0);
    gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);

    compare_evt_addr1 = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE1);
    gpiote_task_addr1 = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER2);


    err_code = nrf_drv_ppi_channel_assign(ppi_channel, compare_evt_addr,gpiote_task_addr);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(ppi_channel1, compare_evt_addr1, gpiote_task_addr1);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_enable(ppi_channel1);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER);
    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER2);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Using 1 PPI channel:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void led_blinking_setup2()
{
    uint32_t compare_evt_addr;
    uint32_t gpiote_task_addr;
    uint32_t compare_evt_addr1;
    uint32_t gpiote_task_addr1;
    uint32_t err_code;
   
    nrf_ppi_channel_t ppi_channel;
    //APP_ERROR_CHECK(err_code);

    //nrf_ppi_channel_t ppi_channel1;
    //APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_config_t config1 = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
    nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_TOGGLE(false); //false reverses the starting state.
    //nrf_drv_gpiote_out_config_t config1 = GPIOTE_CONFIG_OUT_TASK_HIGH;
    //nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_LOW;

   err_code = nrfx_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER, &amp;amp;config1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER2, &amp;amp;config2);
    APP_ERROR_CHECK(err_code);

    uint32_t ticks_RED = nrfx_timer_ms_to_ticks(&amp;amp;timer, 200);

    //nrf_drv_timer_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, (ticks_RED/2), true);
    //nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL1, ticks_RED, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);
    nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, ticks_RED, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);
    //err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel1);
    //APP_ERROR_CHECK(err_code);
 
    compare_evt_addr = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE0);
    gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);

    //compare_evt_addr1 = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE1);
    gpiote_task_addr1 = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER2);


    err_code = nrf_drv_ppi_channel_assign(ppi_channel, compare_evt_addr,gpiote_task_addr);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_fork_assign(ppi_channel, gpiote_task_addr1);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER);
    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER2);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I mentioned using different tasks for setting and clearing the pins. That is a bit difficult using this implementation, because you fetch the address of the task by referencing the pin, but it is possible to set up several tasks per pin. One way is to do the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// This function sets up TIMER3, the PPI and the GPIOTE modules to configure a single PWM channel
// Timer CC num, PPI channel nums and GPIOTE channel num is defined at the top of this file
void pwm0_init(uint32_t pinselect)
{  
    NRF_GPIOTE-&amp;gt;CONFIG[PWM0_GPIOTE_CH] = GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos | 
                                         GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos | 
                                         pinselect &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos | 
                                         GPIOTE_CONFIG_OUTINIT_High &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos;

    NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_A].EEP = (uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;EVENTS_COMPARE[PWM0_TIMER_CC_NUM];
    NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_A].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_CLR[PWM0_GPIOTE_CH];
    NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_B].EEP = (uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;EVENTS_COMPARE[TIMER_RELOAD_CC_NUM];
    NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_B].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_SET[PWM0_GPIOTE_CH];
    
    NRF_PPI-&amp;gt;CHENSET               = (1 &amp;lt;&amp;lt; PWM0_PPI_CH_A) | (1 &amp;lt;&amp;lt; PWM0_PPI_CH_B);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/277111?ContentTypeID=1</link><pubDate>Tue, 27 Oct 2020 11:21:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:461e3843-b454-4a1b-a8d6-c67de3211cbb</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Sorry for the delay. Can you check into the code and see what is missing. I think I am not properly assigning the address to PPI channel.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gpiote.zip"&gt;devzone.nordicsemi.com/.../gpiote.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;kind regards,&lt;/p&gt;
&lt;p&gt;Adarsh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/276544?ContentTypeID=1</link><pubDate>Fri, 23 Oct 2020 07:17:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91c2c083-214d-4aa6-b5e8-b917d3dd75a6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7382.pastedimage1603437377038v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t compile the project. Where do you declare/define config and config2?&lt;/p&gt;
&lt;p&gt;Please try to unzip the project in an unmodified SDK before you upload it. It is a simple way to check that you didn&amp;#39;t do any changes outside the project folder.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/276405?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2020 10:27:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:127c1e53-b7c2-4526-a432-44f84f78a96a</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hai Edvin,&lt;/p&gt;
&lt;p&gt;Sorry for the missleadings.&lt;/p&gt;
&lt;p&gt;As Daniel mensioned I was able to work my application with single ppi channel using fork functionality. The file is &amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gpiote_2D00_-Daniel.zip"&gt;devzone.nordicsemi.com/.../gpiote_2D00_-Daniel.zip&lt;/a&gt; here.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But as you mentioned, there is a risk of one LED to remain in the false state at some time during the application when driven by higher priority interrupt.&lt;/p&gt;
&lt;p&gt;So as you suggested, I initialized two PPI channel. Then I set the timer to run at 20ms and set one compare at 10ms and the other at 20ms. Now I am having difficulties in assigning the tasks to set and clear the pins. Here I am uploading the whole file. Kindly have a look.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/gpiote_2D00_-Edvin.zip"&gt;devzone.nordicsemi.com/.../gpiote_2D00_-Edvin.zip&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Adarsh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/276385?ContentTypeID=1</link><pubDate>Thu, 22 Oct 2020 09:00:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ed9f9e7c-76b7-4a29-9840-02ddc2dd0501</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;This is obviously not your entire application, so it is a bit difficult to say what&amp;#39;s missing.&amp;nbsp;But you should either use two different ppi channels for gpiote_task_addr and gpiote_task_addr1, or you should use the fork functionality, as we discussed earlier.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Other than that, it depends on what you have done outside this snippet. How did you set up your tasks on your gpiote_task_add and gpitoe_task_addr1?&lt;/p&gt;
&lt;p&gt;And did you remember to actually start the timer?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/276301?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2020 17:54:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d0ecf77-7ef8-46bb-8202-84b75a85f663</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hai Edvin,&lt;/p&gt;
&lt;p&gt;If I have understood you right, the below-given code would do the trick right? But I have trouble setting up and clearing the pins. So I have left that line empty.&amp;nbsp;Is my approach correct? If so how can u add up the missing line?&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;static void led_blinking_setup()
{
    uint32_t compare_evt_addr;
    uint32_t gpiote_task_addr;
    uint32_t compare_evt_addr1;
    uint32_t gpiote_task_addr1;
   
    nrf_ppi_channel_t ppi_channel;
    ret_code_t err_code;

   // Here comes the LED SET and CLEAR function

    uint32_t ticks_RED = nrfx_timer_ms_to_ticks(&amp;amp;timer, 20);

    nrf_drv_timer_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, (ticks_RED/2), false);
    nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL1, ticks_RED, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    compare_evt_addr = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE0);
    gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);

    compare_evt_addr1 = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE1);
    gpiote_task_addr1 = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER2);


   

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, compare_evt_addr, gpiote_task_addr);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(ppi_channel, compare_evt_addr1, gpiote_task_addr1);
    APP_ERROR_CHECK(err_code);
    
    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER);
    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER2);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;regards,&lt;/p&gt;
&lt;p&gt;Adarsh&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: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/276133?ContentTypeID=1</link><pubDate>Wed, 21 Oct 2020 09:36:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a398c58e-a619-4732-b370-7291be114f3b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;That looks good!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for pointing out the forking, &lt;a href="https://devzone.nordicsemi.com/members/daniel-chisholm"&gt;Daniel Chisholm&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have given the toggle vs set/clr some thought. When you are using PPI I think you will be just fine using toggle, because the execution of the tasks are not dependent on the CPU. Particularly when you use the Fork functionality, these are based on the same event signal.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you had a toggle functionality that was done in an event handler in your application, which would require the CPU to execute it is more &amp;quot;scary&amp;quot;, because this execution may be interrupted e.g. between the two toggle pin operations, by a higher priority interrupt. In worst case, the event will not be resumed until it occurs again, which may leave one pin in the wrong state.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275998?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 15:25:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fa14ae1-2531-4a66-9564-34317bfc3250</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Oh yeah. Was just a test code. Will include in the main code after testing Edvin&amp;#39;s approach as well. Thank you for pointing out the error. Cheers!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275997?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 15:19:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:accf1113-d97e-4b40-9f41-83eaf2addb2f</guid><dc:creator>Daniel Chisholm</dc:creator><description>&lt;p&gt;Yes, just like that (BTW looks like you forgot to check error return code after line 31)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275995?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 15:15:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8060a30f-f4f3-4b95-9b43-1f6cdfa384f3</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hi Daniel,&lt;/p&gt;
&lt;p&gt;Thanks for your suggestion,&lt;/p&gt;
&lt;p&gt;As per your suggestion, the code would look something like this right?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void led_blinking_setup()
{
    uint32_t compare_evt_addr;
    uint32_t gpiote_task_addr;
    uint32_t gpiote_task_addr2;
    nrf_ppi_channel_t ppi_channel;
    ret_code_t err_code;

    nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(false);
    nrf_drv_gpiote_out_config_t config2 = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);

    err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER, &amp;amp;config);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_gpiote_out_init(GPIO_OUTPUT_PIN_NUMBER2, &amp;amp;config2);
    APP_ERROR_CHECK(err_code);

    uint32_t ticks_RED = nrfx_timer_ms_to_ticks(&amp;amp;timer, 10);

    nrf_drv_timer_extended_compare(&amp;amp;timer, NRF_TIMER_CC_CHANNEL0, ticks_RED, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    compare_evt_addr = nrf_drv_timer_event_address_get(&amp;amp;timer, NRF_TIMER_EVENT_COMPARE0);
    gpiote_task_addr = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER);

    gpiote_task_addr2 = nrf_drv_gpiote_out_task_addr_get(GPIO_OUTPUT_PIN_NUMBER2);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, compare_evt_addr, gpiote_task_addr);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_fork_assign(ppi_channel, gpiote_task_addr2);  
    
    err_code = nrf_drv_ppi_channel_enable(ppi_channel);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER);
    nrf_drv_gpiote_out_task_enable(GPIO_OUTPUT_PIN_NUMBER2);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;But as Edvin suggested it might be safer to set and clear the pins. With that being said, I will test both the approach.&amp;nbsp; Thank you.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Adarsh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275982?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 14:42:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31fca5b1-120c-4262-b528-713a04a187f9</guid><dc:creator>Daniel Chisholm</dc:creator><description>&lt;p&gt;Why not use a single PPI?&amp;nbsp; In addition to its &amp;quot;task endpoint&amp;quot;, you can add a &amp;quot;fork endpoint&amp;quot; too, so in this way from one input a PPI can drive two outputs.&lt;/p&gt;
&lt;p&gt;Setup your two GPIOTEs to toggle, but with opposite initial states.&amp;nbsp; Keep your timer setup to cycle every 10ms with the shortcut (like your have already done). When the one PPI is triggered, it will toggle both of your LEDs simultaneously (and having started out in opposite states, they&amp;#39;ll always be in opposite states)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275967?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 14:05:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ac29976-6810-4bd0-b921-6ef79c2a8945</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;No worries. After I reply to a ticket like this one, it will enter a waiting state and disappear from my queue. When you write something, it will pop back up. Just let me know if you have any issues when you have had time to do some testing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275947?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 13:22:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8449a39c-6dea-4217-9d66-df888fdd786a</guid><dc:creator>Adarsh_1</dc:creator><description>&lt;p&gt;Hai Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;Definitely, I will try your approach and let you know in case of any difficulties within 2 days. Unfortunately, I don&amp;#39;t have the board with me today.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Adarsh&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Toggle 2 LEDs back and forth with PPI, GPIOTE and timer</title><link>https://devzone.nordicsemi.com/thread/275942?ContentTypeID=1</link><pubDate>Tue, 20 Oct 2020 13:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac1321c9-2f37-4b0b-a99f-1038910705be</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;If the two LEDs are always the opposite of one another, I would try to make the two use the same timer for both gpios.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;E.g. see if you can set the timer to run for 20ms, but set one compare at 10ms and one at 20ms. Remember to only&amp;nbsp;NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK at the 20ms compare.&lt;/p&gt;
&lt;p&gt;Then you have to set the ppi channels to turn one LED on and one off at 10ms, and vice versa at 20ms. In theory you should be able to use toggle with opposite starting conditions, but it is safer to set and clear the pins.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Let me know if this was very unclear. I don&amp;#39;t have a project that is set up the same as you, so if you get stuck, please try to upload the project folder (zip it and upload it here).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>