<?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>Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82599/max-measurable-gpio-input-frequency</link><description>Hi all, 
 I have to measure the frequency of a PWM signal routed to one of the nRF52840 GPIO pins. 
 The signal frequency is ~3MHz. 
 The measurement is done with the help of two timers, the code is taken from this thread : 
 
 As long as the PWM frequency</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Jan 2025 14:48:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82599/max-measurable-gpio-input-frequency" /><item><title>RE: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519344?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 14:48:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:678fc906-fa73-48aa-99f9-0b216bce16c3</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ah, sorry. Yes. DPPI. I was looking at the tags in this original DevZone ticket, and they used the nRF52840.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You may want to make sure you don&amp;#39;t use the DPPI channels that the SoftDevice Controller is using, or the&amp;nbsp;timers that softdevice or MPSL that the MPSL library is using:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/softdevice_controller/doc/softdevice_controller.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/softdevice_controller/doc/softdevice_controller.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/mpsl/doc/mpsl.html"&gt;https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/mpsl/doc/mpsl.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Check those links to see which ones that they use. For simplicity, try doing it in a sample without the SoftDevice controller first, to minimize the chances of collisions (using the same peripheral resources).&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: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519279?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 12:15:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34442fc2-db77-426a-b7a3-2826012d21b8</guid><dc:creator>frogrammer</dc:creator><description>&lt;p&gt;Hi Edvin, Thanks for your reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have already added&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Apparantly that doesn&amp;#39;t resolve&amp;nbsp;NRF_PPI not found. Then I searched around found that, it is now NRF_DPPI , I have then changed the line it doesn&amp;#39;t work. My board is nRF5340DK , and the requirement is stable frequency measurement over 6 channels/gpios on top of that bluetooth running. I have managed to do the bluetooth and sensor measurement part but i could not find any proper way to measure frequency with hardware wise. My, SDK is ncs 2.6.1 and toolchain 2.6.1. some examples i try all of them are old examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519220?ContentTypeID=1</link><pubDate>Tue, 21 Jan 2025 09:15:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb9d454d-6d4d-43dc-801a-eaa356dac9df</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Ah,&lt;/p&gt;
&lt;p&gt;Try including the zephyr kernel:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/kernel.h&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That will then include the rest so that it knows what the nRF52840 board&amp;#39;s registers are.&lt;/p&gt;
&lt;p&gt;As for the log, that is a bit different. The logging in NCS uses LOG_INF() instead of NRF_LOG_INFO(). To enable it you need to:&lt;/p&gt;
&lt;p&gt;1: add this to your prj.conf:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=y
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then add this to the top of your main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/logging/log.h&amp;gt;

#define LOG_MODULE_NAME app
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

// For testing:
int main(void)
{
    LOG_INF(&amp;quot;Hello World! %s&amp;quot;, CONFIG_BOARD_TARGET);
}&lt;/pre&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: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519150?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2025 17:22:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3aa63c01-65e8-4e58-9a04-4a2f9dfbc9ca</guid><dc:creator>frogrammer</dc:creator><description>&lt;p&gt;I have tried compiling this code but these are the errors :&lt;pre class="ui-code" data-mode="powershell"&gt;C:/ncs/test/freq_calc/src/main.c: In function &amp;#39;ppi_timer_stop_counter_init&amp;#39;:
C:/ncs/test/freq_calc/src/main.c:49:3: error: &amp;#39;NRF_PPI&amp;#39; undeclared (first use in this function); did you mean &amp;#39;NRF_SPU&amp;#39;?
   49 |   NRF_PPI-&amp;gt;CHEN |= 1 &amp;lt;&amp;lt; 0;
      |   ^~~~~~~
      |   NRF_SPU
C:/ncs/test/freq_calc/src/main.c:49:3: note: each undeclared identifier is reported only once for each function it appears in
C:/ncs/test/freq_calc/src/main.c: In function &amp;#39;ppi_gpiote_counter_init&amp;#39;:
C:/ncs/test/freq_calc/src/main.c:57:3: error: &amp;#39;NRF_PPI&amp;#39; undeclared (first use in this function); did you mean &amp;#39;NRF_SPU&amp;#39;?
   57 |   NRF_PPI-&amp;gt;CHEN |= 1 &amp;lt;&amp;lt; 1;
      |   ^~~~~~~
      |   NRF_SPU
C:/ncs/test/freq_calc/src/main.c: In function &amp;#39;main&amp;#39;:
C:/ncs/test/freq_calc/src/main.c:65:25: warning: implicit declaration of function &amp;#39;NRF_LOG_INIT&amp;#39;; did you mean &amp;#39;Z_LOG_INST&amp;#39;? [-Wimplicit-function-declaration]
   65 |     uint32_t err_code = NRF_LOG_INIT(NULL);
      |                         ^~~~~~~~~~~~
      |                         Z_LOG_INST
C:/ncs/test/freq_calc/src/main.c:72:5: warning: implicit declaration of function &amp;#39;NRF_LOG_DEFAULT_BACKENDS_INIT&amp;#39; [-Wimplicit-function-declaration]
   72 |     NRF_LOG_DEFAULT_BACKENDS_INIT();
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/test/freq_calc/src/main.c:73:5: warning: implicit declaration of function &amp;#39;NRF_LOG_INFO&amp;#39; [-Wimplicit-function-declaration]
   73 |     NRF_LOG_INFO(&amp;quot;Timer Test&amp;quot;);
      |     ^~~~~~~~~~~~
C:/ncs/test/freq_calc/src/main.c:75:35: error: &amp;#39;APP_IRQ_PRIORITY_LOW&amp;#39; undeclared (first use in this function); did you mean &amp;#39;NRFY_IRQ_PRIORITY_SET&amp;#39;?
   75 |     NVIC_SetPriority(TIMER1_IRQn, APP_IRQ_PRIORITY_LOW);
      |                                   ^~~~~~~~~~~~~~~~~~~~
      |                                   NRFY_IRQ_PRIORITY_SET
C:/ncs/test/freq_calc/src/main.c:90:7: warning: implicit declaration of function &amp;#39;NRF_LOG_FLUSH&amp;#39; [-Wimplicit-function-declaration]
   90 |       NRF_LOG_FLUSH();
      |       ^~~~~~~~~~~~~
C:/ncs/test/freq_calc/src/main.c:65:14: warning: unused variable &amp;#39;err_code&amp;#39; [-Wunused-variable]
   65 |     uint32_t err_code = NRF_LOG_INIT(NULL);
      |              ^~~~~~~~
[52/149] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/logging/log_core.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: &amp;#39;C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE&amp;#39; --build &amp;#39;c:\ncs\test\freq_calc\build_1&amp;#39;

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Initially, i had errors with&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;NRF_GPIOTE ,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;NRF_TIMER2 then i have added the header file &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;nrfx_timer.h&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&lt;span&gt;&amp;lt;nrfx_gpiote.h&amp;gt;&amp;#39;&amp;#39; and it went away however, the NRF_PPI seems to be needed a library reference, which is i am not sure how to adjust. Aparently, NRF_LOG() / NRF_LOG_FLUSH() macro isnt supported anymore? found it through a discussion on this devzone, can i easily replace it by &amp;#39;&amp;#39;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;#include&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;zephyr/logging/log.h&amp;gt;&amp;#39;&amp;#39; , would you mind checking both issues?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519113?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2025 14:33:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7086f764-8871-48d9-a187-2d1af4757d47</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Yes, that is a different SDK, which is not Zephyr.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;try ignoring the includes on the top of the snippet above. As long as the code builds before you add those snippets, you shouldn&amp;#39;t need anything else. These are bare metal registers, so they are not part of any library.&lt;/p&gt;
&lt;p&gt;Try running it in a sample that doesn&amp;#39;t do much else at first, such as the ncs\zephyr\samples\hello_world. And try to not use TIMER0 or RTC0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="frogrammer"]will it be possible to have&amp;nbsp; 6 instances of these measurements[/quote]
&lt;p&gt;I don&amp;#39;t know the logics in this sample (it was the other user&amp;#39;s code, so I didn&amp;#39;t test it). The limiting factor would be the number of CC registers in the timer instance that you are using. They seem to be 8 (0-7) on all timer instances on the nRF5340.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf5340/page/timer.html#ariaid-title28"&gt;https://docs.nordicsemi.com/bundle/ps_nrf5340/page/timer.html#ariaid-title28&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: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/519059?ContentTypeID=1</link><pubDate>Mon, 20 Jan 2025 12:44:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bca57c2e-39ff-4067-a46a-6184dc16a3e3</guid><dc:creator>frogrammer</dc:creator><description>&lt;p&gt;Hi, I would like to use this method to measure continuously changing frequency onto a gpio pin on my nrf5340dk running nCS V2.6.1 , however, above exact code splits out error, I am assuming it is regarding the include files which in my case always starts with &amp;#39;&amp;#39;zephyr/...&amp;#39;&amp;#39; , I did couple of these changes but error persist. Also, I need some idea on which configuration lines on prj.config this code is using? another question is , will it be possible to have&amp;nbsp; 6 instances of these measurements?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max. measurable GPIO input frequency</title><link>https://devzone.nordicsemi.com/thread/343219?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 14:23:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1e45ece-f796-408e-b59d-8c2c1e69eb1c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello hypn0,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply. Without having checked or done the math, I believe this frequency is about the maximum frequency possible to measure using PPI.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The PPI itself is running at 16MHz. There i up to 1 tick delay on the PPI, so that gives you a 8MHz. The you have some delay in the GPIO itself. The pad capacitance is 5pF. Depending on the input signal you are measuring it will take a certain amount of time from you set the output high until the input on the nRF is actually pulled high. If this takes a few µs, then that would explain the delay you are seeing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you try to use a logic analyzer to measure your input signal, and then use the PPI to toggle a pin on every GPIO event (so that you basically duplicate the input signal), what sort of delay are you seeing between the (PWM) input and the (GPIO) output using the PWM generator that you are using?&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>