<?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>UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121252/uart-fs-logging-backend-with-grtc-driven-egu-interrupt-slows-down-logging-output</link><description>Hello, I am working on incorporating flash logging into an application that has a GRTC-driven EGU interrupt (capture/compare event). Here is where I am setting up the EGU and connecting it to the GRTC Capture/Compare event with a PPI channel. The GRTC</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 16 May 2025 14:17:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121252/uart-fs-logging-backend-with-grtc-driven-egu-interrupt-slows-down-logging-output" /><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/535820?ContentTypeID=1</link><pubDate>Fri, 16 May 2025 14:17:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89994158-ea02-4ad5-b798-15f59900cbc6</guid><dc:creator>Vidar Berg</dc:creator><description>[quote user="br_adams_01"]For #4, if I only use the window size and interval, apparently the RX mode is still enabled, and I get ~5 mA of constant average current as a result. So I have to enable and disable scanning with periodic interrupts to achieve the same effect, but by disabling RX as a result.[/quote]
&lt;p&gt;This should be about as expected if you are scanning with a 100 % duty cycle @ 1.8v (scan window == scan interval) -&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/power/w/opp/2/online-power-profiler-for-bluetooth-le"&gt;Online Power Profiler for Bluetooth LE&lt;/a&gt;&amp;nbsp;&amp;nbsp;.&amp;nbsp;The timeout/duration can be specified via the timeout field of the bt_le_scan_param struct.&lt;/p&gt;
[quote user="br_adams_01"]For #5, EGU triggers 1 second after program start to turn scanning on, and then EGU triggers again 30 seconds later to turn scanning off. After that, I stop scanning for 30 minutes (1800 seconds) before I trigger the EGU to turn scanning on again, and this happens in a cycle.&lt;br /&gt;[/quote]
&lt;p&gt;There must be a bug somewhere if using a zephyr timer instance with this interval (&lt;a href="https://docs.zephyrproject.org/latest/kernel/services/timing/timers.html#defining-a-timer"&gt;https://docs.zephyrproject.org/latest/kernel/services/timing/timers.html#defining-a-timer&lt;/a&gt;) leads to a&amp;nbsp;measurable increase in current consumption.&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/121544/how-to-make-the-intermittent-application-with-grtc-and-lfxo-while-asleep"&gt;How to make the Intermittent application with GRTC and LFXO while asleep.&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
[quote user="br_adams_01"]However, I will try to change to the Zephyr timer module to see the result.[/quote]
&lt;p&gt;Please let me know when you&amp;#39;ve had a chance to try this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/535669?ContentTypeID=1</link><pubDate>Thu, 15 May 2025 21:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:398de67b-946e-441f-9684-e508d16409c6</guid><dc:creator>br_adams_01</dc:creator><description>&lt;p&gt;I&amp;#39;m glad you mentioned the first point (#1), because I found something I may could try.&lt;br /&gt;&lt;br /&gt;According to that integration note, it is stated that reconfiguring the interrupts for the GRTC while MPSL is enabled is not allowed. However, I could try to set the following Kconfig to true, which would allow me to reconfigure the interrupts:&lt;br /&gt;&lt;br /&gt;&lt;a class="reference external" title="(in Kconfig reference v&amp;amp;nbsp;)" href="https://docs.nordicsemi.com/bundle/ncs-latest/page/kconfig/index.html#CONFIG_MPSL_DYNAMIC_INTERRUPTS" data-bundleid="ncs-latest" data-navpath="kconfig/index.html"&gt;&lt;code class="xref kconfig kconfig-option docutils literal notranslate"&gt;&lt;span class="pre"&gt;CONFIG_MPSL_DYNAMIC_INTERRUPTS&lt;/span&gt;&lt;/code&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I have not tried thought #2 yet. &lt;br /&gt;&lt;br /&gt;For #3, I have not measured the current consumption in this state. &lt;br /&gt;&lt;br /&gt;For #4, if I only use the window size and interval, apparently the RX mode is still enabled, and I get ~5 mA of constant average current as a result. So I have to enable and disable scanning with periodic interrupts to achieve the same effect, but by disabling RX as a result. &lt;br /&gt;&lt;br /&gt;For #5, EGU triggers 1 second after program start to turn scanning on, and then EGU triggers again 30 seconds later to turn scanning off. After that, I stop scanning for 30 minutes (1800 seconds) before I trigger the EGU to turn scanning on again, and this happens in a cycle.&lt;br /&gt;&lt;br /&gt;I am going to try the above Kconfig and see what happens.&lt;br /&gt;&lt;br /&gt;UPDATE: The above Kconfig did not work. However, I will try to change to the Zephyr timer module to see the result.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/535663?ContentTypeID=1</link><pubDate>Thu, 15 May 2025 17:59:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39f1a969-9e6f-453b-bf35-498a83dcbadc</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Sorry, I see now from your initial post that you were not using direct interrupts. I missed that earlier.&lt;/p&gt;
&lt;p&gt;Some thoughts:&lt;/p&gt;
&lt;p&gt;1. There may be a possible conflict with GRTC usage in MPSL and Zephyr (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrfxlib/mpsl/doc/mpsl.html"&gt;Integration notes&lt;/a&gt;). Though I don&amp;#39;t know how that could affect the logger thread&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2. Did you submit the same workqueue item from the zephyr timer handler earlier without encountering this issue?&lt;/p&gt;
&lt;p&gt;3.&amp;nbsp;In the case where you only&amp;nbsp;get one log message ~1 every second,&amp;nbsp;what&amp;#39;s&amp;nbsp;the approx. current consumption and length of the idle periods? Or in other words, does the power profile show that the device is spending the majority of the time in sleep still?&lt;/p&gt;
&lt;p&gt;4. Why even use a periodic interrupt to start and stop scanner? Can&amp;#39;t the same be achieved more effeciently by setting the window size, interval, and timeout with the scanner API?&lt;/p&gt;
&lt;p&gt;5. What&amp;#39;s the EGU trigger interval approx.?&lt;/p&gt;
&lt;p&gt;I would also be happy to try troubleshoot this further on my end if you are able to share a minimal version of your project.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/535405?ContentTypeID=1</link><pubDate>Wed, 14 May 2025 17:59:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6272c49a-984b-434b-8e46-2135ea5f2e5a</guid><dc:creator>br_adams_01</dc:creator><description>&lt;p&gt;Vidar,&lt;br /&gt;&lt;br /&gt;The workqueue item I am referring to does not have any blocking functions within or endless loops within. They are really short workqueue handlers (in my case, one that turns Bluetooth scanning on, and another one that turns Bluetooth scanning off in order to further save power). These workqueue items only execute when the EGU interrupt is triggered. So it should happen quick enough. And I do not think they are direct, as I am using IRQ_CONNECT as opposed to IRQ_DIRECT_CONNECT to tie the IRQ line to the ISR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/534600?ContentTypeID=1</link><pubDate>Fri, 09 May 2025 09:35:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:250581f5-f4fd-400b-bdb4-22f54ed9536a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for the additional information.&amp;nbsp;I can understand if the idle current is lower&amp;nbsp;if the timer timeout interval is short (in the low millisecond range rather than in the seconds range), and if your ISR is shorter with less CPU overhead compared to using the GRTC ISR in zephyr.&lt;/p&gt;
[quote user="br_adams_01"]So instead we use a GRTC/EGU interrupt connected with a PPI channel, and then we use the ISR (very short) to submit a workqueue function to do X action.[/quote]
&lt;p&gt;Are you using &amp;quot;direct&amp;quot; interrupts as in this case:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/121295/large-delay-between-k_signal_raise-and-k_poll-invocation"&gt;Large delay between k_signal_raise and k_poll invocation&lt;/a&gt;&amp;nbsp;?&amp;nbsp;&amp;nbsp;And could the slowdown be caused by the workqueue item you submitted (could&amp;nbsp;it block the logger thread for a longer period)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/534329?ContentTypeID=1</link><pubDate>Wed, 07 May 2025 15:44:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b6b8566f-1e3b-47ad-86e4-0e7b6b0738f8</guid><dc:creator>br_adams_01</dc:creator><description>&lt;p&gt;Vidar,&lt;br /&gt;&lt;br /&gt;Enabling the interrupt with flash backend disabled results in the same amount of log messages being printed within a certain time-frame (no change in logging speed). The interrupt frequency varies, as we set a value in the compare register for the GRTC and then the interrupt gets triggered when the counter value reaches the compare value. When that happens, we set another compare value either at that instant or at some later point in the program when we need to use the timed interrupt again (by setting the next interrupt time based on the current counter value plus a set time in microseconds). As I stated above, I have profiled both, and the GRTC actually does use less energy (by about 60 uA). It&amp;#39;s especially beneficial when the counter/timer needs to run for the entire runtime on a battery powered device.&lt;br /&gt;&lt;br /&gt;This is some measurements that I did in the past (end of last year) with idle current with GRTC vs. Zephyr timer module.&lt;br /&gt;&lt;br /&gt;The green trace represents the Zephyr timer module and the yellow trace represents the GRTC. There is about a 56 uA increase when using the Zephyr timer module for timed workqueue functions.&lt;br /&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1746632240188v1.png" /&gt;&lt;br /&gt;&lt;br /&gt;So instead we use a GRTC/EGU interrupt connected with a PPI channel, and then we use the ISR (very short) to submit a workqueue function to do X action.&lt;br /&gt;&lt;br /&gt;Yes, the flash logging backend is slower from observation, but not too slow. When using the GRTC/EGU interrupt, however, it causes significant slowdowns to the flash logging backend (along the order of about 1-2 log lines every second).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART/FS Logging Backend with GRTC-driven EGU Interrupt slows down logging output</title><link>https://devzone.nordicsemi.com/thread/534325?ContentTypeID=1</link><pubDate>Wed, 07 May 2025 15:22:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84326533-aa48-4514-9422-ad5b6a26f8b2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Does enabling this interrupt result in significantly more log messages being printed (with flash backend disabled)? And what is the frequency of this interrupt, and is it a&amp;nbsp;short ISR?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The flash backend should be&amp;nbsp;considerably slower and may be blocking the uart backend.&lt;/p&gt;
[quote user=""]The GRTC is used for timed interrupts so that I do not have to use the Zephyr timer module (uses more energy).[/quote]
&lt;p&gt;I haven&amp;#39;t profiled this (maybe you have), but I would not expect there to be a significant difference here. Zephyr timers use the same GRTC peripheral as the interrupt source.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>