<?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>nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50228/nrf52840---giving-userdefined-function-at-ppi-task-end</link><description>Hello, 
 We were just wondering if it is possible to give user-defined function at the PPI TEP instead of starting timer or generating some GPIOTE task. 
 Is it possible to configure a PPI channel where there is a GPIOTE event and as per the occurrence</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 01 Aug 2019 11:52:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50228/nrf52840---giving-userdefined-function-at-ppi-task-end" /><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201849?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2019 11:52:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c58432b4-029f-493c-9606-5edc8d554f11</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Thanks for your suggestion. Now there is no unnecessary interrupts when the pulse is removed from the GPIO.&lt;/p&gt;
&lt;p&gt;As we have a very narrow timeline for capturing the image, we want to calculate the machine cycle of the subroutine and total available machine cycles for the controller. Is there any document/reference from where we can get this information?&lt;/p&gt;
&lt;p&gt;Also, we are capturing parallel port data. Is there any better way for storing the image on device? I have gone through the demo of flash data storage. Will it be appropriate to use flash storage considering very tight timeline (high rate of input data)?&lt;/p&gt;
&lt;p&gt;Can we write subroutine for EGU in assembly? Will it reduce number of machine cycles it takes to execute the subroutine?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201321?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 14:49:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3762a2d9-bcec-4051-9ffa-393c9a3ab140</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry. I should have noticed.&lt;/p&gt;
&lt;p&gt;In your egu event handler you should use:&lt;/p&gt;
&lt;p&gt;NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[0] = 0;&lt;/p&gt;
&lt;p&gt;not&lt;/p&gt;
&lt;p&gt;NRF_EGU1-&amp;gt;TASKS_TRIGGER[0] = 0;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also see that something triggered NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[1]. Not sure exactly what that is. I didn&amp;#39;t get the time to look properly at it, but maybe you figure it out before tomorrow (Not sure where you are situated).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I added:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[0] = 0;&lt;br /&gt;&lt;/span&gt;&lt;span&gt;NRF_EGU1-&amp;gt;EVENTS_TRIGGERED[1] = 0;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And then it stopped calling the EGU event handler. Maybe some other library is using EGU1, and you can try another EGU (to prevent EVENTS_TRIGGERED[1] from triggereng the event handler.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Edvin&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201173?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 09:08:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98102bab-7e10-4a46-8bd2-8d95c5d66ad3</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;Yes, it is possible to reproduce on DK. Timer interrupt toggles pin 0.05 on DK and EGU is triggered by the event on pin 0.02&lt;/p&gt;
&lt;p&gt;Attached is the project.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/nrf52_2D00_ble_2D00_image_2D00_transfer_2D00_demo.zip"&gt;devzone.nordicsemi.com/.../nrf52_2D00_ble_2D00_image_2D00_transfer_2D00_demo.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201129?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 07:16:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b3f6b64-ba3c-4909-89dc-85ad140d3823</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Is it possible to reproduce this on a DK? If so, would it be possible to send a project that can reproduce this, so that I can test it and see what&amp;#39;s going on?&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: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201103?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 05:39:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be450292-cc76-49ed-9b38-475adac36003</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;I don&amp;#39;t think that is the issue, this is because when I remove the input pulse from the GPIO then also the counter keeps on increment.&lt;/p&gt;
&lt;p&gt;I tried with timer of 10ms. Then also, when first event occurs at PPI event end, the execution of&amp;nbsp;&lt;span&gt;SWI1_EGU1_IRQHandler() starts endlessly. If I remove the input pulse at runtime (by removing input from GPIO pin) then also the counter keeps on increment.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201027?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 14:44:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:754275b3-a534-45f6-acb7-295b0b5a154c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;can you try to trigger the PPI event less often, i.e. have an input pulse with a lower frequency to see if this is actually the issue? (you can use a timer to generate a pulse on one of the GPIOs that you input to your PPI pin)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/201021?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2019 14:28:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:147c6c4f-5802-40b1-9833-5eb44eadc3a2</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;I added below line of code in IRQ Handler.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_EGU1-&amp;gt;TASKS_TRIGGER[0] = 0;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But still there is no change in behaviour. It continuously executes the IRQ handler and none of the other logic is executed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there any document for clock cycle, such that we can understand the machine cycle consumed in each instruction?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/200771?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 12:45:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e122e734-d18d-440e-886a-5bb8bea183d1</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I am not sure, but I think I saw something similar when I tested the project that I sent you.&lt;/p&gt;
&lt;p&gt;I thought that it stopped the other PPI events from happening (LED1 stopped, but LED2 kept on blinking). I figured this was because the EGU triggered too often, so that the application layer never got any time to update the TIMER-&amp;gt;CC[] registers. If you have interruptions at 1MHz, then you don&amp;#39;t have many clock cycles to run your SWI_EGU1_IRQHandler() before the interrupt triggers again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, I see that you don&amp;#39;t reset the EGU event. Can you try to add:&lt;/p&gt;
&lt;p&gt;NRF_EGU1-&amp;gt;TASKS_TRIGGER[0] = 0;&lt;/p&gt;
&lt;p&gt;in your&amp;nbsp;SWI1_EGU1_IRQHandler()?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/200759?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2019 12:05:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6df6d7c-457d-4bff-83fe-6feb3528bb7d</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;Thanks for the demo code,&lt;/p&gt;
&lt;p&gt;I used in my application and it works as expected. However while debugging in Segger Embedded Studio we found something interesting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void SWI1_EGU1_IRQHandler(void)
{
    ++m_counter;
}

void egu_init(void)
{
    NVIC_ClearPendingIRQ(SWI1_EGU1_IRQn);
    NVIC_EnableIRQ(SWI1_EGU1_IRQn);
    NRF_EGU1-&amp;gt;INTENSET = (1 &amp;lt;&amp;lt; 0) | (1 &amp;lt;&amp;lt; 1);
}

static void ppi_init(void)
{
    uint32_t err_code = NRF_SUCCESS;
    nrf_drv_gpiote_in_config_t config = NRFX_GPIOTE_RAW_CONFIG_IN_SENSE_LOTOHI(true);
    config.pull = NRF_GPIO_PIN_NOPULL;
    uint32_t gpiote_event_addr;
    nrfx_gpiote_uninit();

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
    //nrfx_gpiote_in_uninit(PIN_NUMBER);

    /* Configure 1st available PPI channel to stop TIMER0 counter on TIMER1 COMPARE[0] match,
     * which is every even number of seconds.
     */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel1);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_gpiote_in_init(PIN_NUMBER, &amp;amp;config, gpiote_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_gpiote_in_event_enable(PIN_NUMBER, false);

    gpiote_event_addr = nrf_drv_gpiote_in_event_addr_get(PIN_NUMBER);


    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1,
                                          gpiote_event_addr,
                                          (uint32_t)&amp;amp;NRF_EGU1-&amp;gt;TASKS_TRIGGER[0]);

    APP_ERROR_CHECK(err_code);

    NRF_PPI-&amp;gt;CHENSET                 = (1 &amp;lt;&amp;lt; m_ppi_channel1);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Above is the code snippet which we made by the help of the demo you share. Below is our observation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The egu_init() is successful. ppi_init is also successful.&lt;/li&gt;
&lt;li&gt;When the routine of ppi_init get&amp;#39;s completed specially when ppi channel is enabled, the code gets stuck (I guess in IRQHandler) and m_counter keeps on increment. The thing to be noted is there is continuous input event on the GPIO configured in GPIOTE at the frequency of 1MHz.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Is this a expected behaviour? As we have another logic to be performed after ppi_init, we might not want to get stuck in&amp;nbsp;&lt;span&gt;IRQHandler. Is there any configuration which we missed? or am I understanding it incorrectly?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/200567?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 14:05:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6ac3f5a-3f81-419b-b306-0d415a324a43</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;See the attached&amp;nbsp;project. It should work in SDK15.3.0.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It is a bare-metal approach for PWM using GPIOTE, TIMER and PPI. I changed one of the pins to trigger an EGU to get a callback and toggle the pin instead of toggling directly from the GPIOTE.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that there aren&amp;#39;t any EGU drivers, so I think this bare-metal approach is the best I can give.&lt;/p&gt;
&lt;p&gt;PS: it is a modified blinky project. Since it doesn&amp;#39;t use any drivers, it should work by replacing the main.c file in any SDK example.&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c9aae90cd77a479eb0a412b6eb2b00f1/PPI_5F00_EGU_5F00_example.zip"&gt;devzone.nordicsemi.com/.../PPI_5F00_EGU_5F00_example.zip&lt;/a&gt;&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: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/200455?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 09:38:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa480e23-0aae-45b1-97f9-c0ec40c23097</guid><dc:creator>Aliasgar Surti</dc:creator><description>&lt;p&gt;Okay, understood the concept of EGU.&lt;/p&gt;
&lt;p&gt;But didn&amp;#39;t get how to make it functional.&lt;/p&gt;
&lt;p&gt;Can you please provide a demo code for that? or any further reference regarding that will be useful.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - giving userdefined function at PPI task end</title><link>https://devzone.nordicsemi.com/thread/200446?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2019 09:14:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d7b0186-5c31-43e5-a962-4fb94a1a136c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Sorry, the previous reply was from a spam-bot. I reported it, and the reply was deleted, along with your answer to it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can try to use &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fegu.html&amp;amp;cp=3_0_0_5_7" rel="noopener noreferrer" target="_blank"&gt;EGU&lt;/a&gt; (event generator unit) to trigger a SW interrupt event from the PPI. To get some help to set it up, check out &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/8307/directions-to-use-egu-peripheral-in-nrf52" rel="noopener noreferrer" target="_blank"&gt;this ticket&lt;/a&gt;, and let me know if you are stuck somewhere.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>