<?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>Outputting 32.768kHz clock signal to a GPIO using GPIOTE and DPPI on an nRF5340-DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108084/outputting-32-768khz-clock-signal-to-a-gpio-using-gpiote-and-dppi-on-an-nrf5340-dk</link><description>Hello, 
 I am trying to measure the frequency of the 32.768kHz crystal on the nRF5340-DK in order to determine if requires calibration, as I am getting a large amount of drift when using it as a real-time clock. I found a way to do this on an nRF52840</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 07 Feb 2024 11:09:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108084/outputting-32-768khz-clock-signal-to-a-gpio-using-gpiote-and-dppi-on-an-nrf5340-dk" /><item><title>RE: Outputting 32.768kHz clock signal to a GPIO using GPIOTE and DPPI on an nRF5340-DK</title><link>https://devzone.nordicsemi.com/thread/467893?ContentTypeID=1</link><pubDate>Wed, 07 Feb 2024 11:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0107766c-0657-4373-b0d6-20661c70e0a4</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am not sure which source your code is based on,&amp;nbsp;but I can see that you are setting up the endpoints for ppi channel:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Connect TICK event of the RTC to the output pin using PPI and GPIOTE
NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_RTC0-&amp;gt;EVENTS_TICK;
NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can also see that this is something which is being done in the&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nrf_ppi_channel_endpoint_setup()&lt;/span&gt; function that is available in the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;nrf_ppi.h&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_STATIC_INLINE void nrf_ppi_channel_endpoint_setup(NRF_PPI_Type *    p_reg,
                                                      nrf_ppi_channel_t channel,
                                                      uint32_t          eep,
                                                      uint32_t          tep)
{
    p_reg-&amp;gt;CH[(uint32_t) channel].EEP = eep;
    p_reg-&amp;gt;CH[(uint32_t) channel].TEP = tep;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As on the 5340, there is DPPI, you can start by looking at the nrf_dppi.h and nrfx_gppi.h (within this file we have if-defined block that checks whether it is PPI or the DPPI) and the source files.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For example, in the nrfx_gppi_dppi.c, we have:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrfx_gppi_event_endpoint_setup(uint8_t channel, uint32_t eep)
{
    NRFX_ASSERT(eep);
    NRF_DPPI_ENDPOINT_SETUP(eep, channel);
}

void nrfx_gppi_task_endpoint_setup(uint8_t channel, uint32_t tep)
{
    NRFX_ASSERT(tep);
    NRF_DPPI_ENDPOINT_SETUP(tep, channel);
}

void nrfx_gppi_channel_endpoints_setup(uint8_t  channel, uint32_t eep, uint32_t tep)
{
    nrfx_gppi_event_endpoint_setup(channel, eep);
    nrfx_gppi_task_endpoint_setup(channel, tep);
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;where the MACRO (as below) defined in the nrf_dppi.h is used:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define NRF_DPPI_ENDPOINT_SETUP(task_or_event, dppi_chan)                                        \
        (*((volatile uint32_t *)(task_or_event + NRF_SUBSCRIBE_PUBLISH_OFFSET(task_or_event))) = \
            ((uint32_t)dppi_chan | NRF_SUBSCRIBE_PUBLISH_ENABLE))&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So probably you can call those functions available in the header files.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;/BR, Naeem&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>