<?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>sys_clock_tick_get problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111424/sys_clock_tick_get-problem</link><description>Hi, 
 I want to get the tick count of the system with sys_clock_tick_get(). I am using a library for NFC reader chip ST25R3916B and provided library from STM requires a platform-dependent tick function to get the number of ticks each ms. I found sys_clock_tick_get</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 25 May 2024 18:43:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111424/sys_clock_tick_get-problem" /><item><title>RE: sys_clock_tick_get problem</title><link>https://devzone.nordicsemi.com/thread/485912?ContentTypeID=1</link><pubDate>Sat, 25 May 2024 18:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ddfa8e6-e636-4c20-9d90-72a75c7f80fe</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;Thank you very much. I redesigned my code, I created a work item and in ISR I submit work item to the system queue. I don&amp;#39;t get the error anymore and code works as expected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sys_clock_tick_get problem</title><link>https://devzone.nordicsemi.com/thread/485911?ContentTypeID=1</link><pubDate>Sat, 25 May 2024 18:42:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57953321-8050-40ce-81e0-27ef15449407</guid><dc:creator>kahlenberg</dc:creator><description>&lt;p&gt;Thank you for testing, but I solved the problem by creating a work queue and submit a work in ISR.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sys_clock_tick_get problem</title><link>https://devzone.nordicsemi.com/thread/485861?ContentTypeID=1</link><pubDate>Fri, 24 May 2024 14:04:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3af59094-f32e-4432-b0f3-e2af3da7fe2d</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Mubin,&lt;/p&gt;
&lt;p&gt;I am not sure what your project looks like, but I would suggest you do some debugging.&lt;/p&gt;
&lt;p&gt;I can call that function in the button callback as below:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1716559441913v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sys_clock_tick_get problem</title><link>https://devzone.nordicsemi.com/thread/485592?ContentTypeID=1</link><pubDate>Thu, 23 May 2024 09:58:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:415549b6-2d1a-4f6f-97a4-28247f15e141</guid><dc:creator>ladybug</dc:creator><description>&lt;p&gt;The error you&amp;#39;re encountering, a kernel panic with assertion failure during interrupt handling, suggests that there&amp;#39;s an issue with how the `sys_clock_tick_get()` function is being called from within the GPIO ISR.&lt;/p&gt;
&lt;p&gt;Interrupt service routines (ISRs) in Zephyr have certain constraints and limitations, and calling certain functions, especially those that involve synchronization primitives like semaphores, from within an ISR can lead to unpredictable behavior, including kernel panics.&lt;/p&gt;
&lt;p&gt;Here are a few potential causes and solutions:&lt;/p&gt;
&lt;p&gt;1. Interrupt Context Safety: Ensure that the `sys_clock_tick_get()` function is safe to call from within an ISR. Check the documentation or implementation details of the function to see if it explicitly states whether it&amp;#39;s ISR-safe.&lt;/p&gt;
&lt;p&gt;2. Blocking Calls: Avoid making blocking or long-running calls from within ISRs. If `sys_clock_tick_get()` or any function it calls internally involves blocking operations or takes a significant amount of time to execute, it should not be called from within an ISR.&lt;/p&gt;
&lt;p&gt;3. Synchronization Primitives: The assertion failure in `sem.c` suggests that there might be an issue related to semaphore usage. If `sys_clock_tick_get()` or any function it calls internally attempts to acquire or release a semaphore, it should not be called from within an ISR. Consider redesigning your code to avoid such dependencies from within ISRs.&lt;/p&gt;
&lt;p&gt;4. Critical Sections: If `sys_clock_tick_get()` involves accessing shared resources that may be modified concurrently by other ISRs or the main execution context, consider using appropriate locking mechanisms such as disabling interrupts (`irq_lock()` and `irq_unlock()`) or using atomic operations (`atomic_*` functions) to protect critical sections of code.&lt;/p&gt;
&lt;p&gt;5. Debugging: Review the stack trace and analyze the execution context leading up to the kernel panic. Identify any potential sources of contention or unsafe operations within the ISR or functions called from it.&lt;/p&gt;
&lt;p&gt;By ensuring that your ISR adheres to the safety and performance guidelines outlined in the Zephyr documentation, you should be able to resolve the kernel panic issue when calling `sys_clock_tick_get()` from within the GPIO ISR. &lt;span style="color:#ffffff;font-size:75%;"&gt;&lt;a style="color:#ffffff;" href="https://geometry-free.com"&gt;geometry dash&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>