<?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>GPIO callback crashes when I2C function runs</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99971/gpio-callback-crashes-when-i2c-function-runs</link><description>Hello, 
 i wrote an I2C driver for MCP9808 temperature sensor (driver is a bit more complex than the one already available in Zephyr). The driver library has been properly debugged and now i&amp;#39;m writing my main.c to embed GPIO interrupt functionalities</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 May 2023 15:03:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99971/gpio-callback-crashes-when-i2c-function-runs" /><item><title>RE: GPIO callback crashes when I2C function runs</title><link>https://devzone.nordicsemi.com/thread/427580?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 15:03:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60ced04f-4932-4eb3-acee-8fe8b3b00514</guid><dc:creator>frax84</dc:creator><description>&lt;p&gt;Got it! Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO callback crashes when I2C function runs</title><link>https://devzone.nordicsemi.com/thread/427500?ContentTypeID=1</link><pubDate>Thu, 25 May 2023 11:34:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa9b3069-0a92-4e58-b5e4-0a8a278632cf</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;The rule of thumb is to not put blocking function calls (synchronous API routines) in callback handlers.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m surprised your code didn&amp;#39;t crash at i2c_write_read_dt, but it might just block for a short enough time to not be an issue.&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO callback crashes when I2C function runs</title><link>https://devzone.nordicsemi.com/thread/427130?ContentTypeID=1</link><pubDate>Wed, 24 May 2023 08:33:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbf2a399-1feb-4975-8a59-be00caa186c9</guid><dc:creator>frax84</dc:creator><description>&lt;p&gt;Hello Einar,&lt;/p&gt;
&lt;p&gt;thank you for your feedback. I supposed that this could be the issue, but i wanted to understand if there could be something i was missing. The reference on the semaphore is very interesting. Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIO callback crashes when I2C function runs</title><link>https://devzone.nordicsemi.com/thread/426907?ContentTypeID=1</link><pubDate>Tue, 23 May 2023 12:19:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bacc2fe-f0d2-4c0a-95c2-89114060027f</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;I would advise against running things like i2c write/read in callback handlers as you&amp;#39;re likely to run into this sort of issue.&lt;/p&gt;
&lt;p&gt;Instead I would suggest signaling from the callback handler with a &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/synchronization/semaphores.html"&gt;semaphore&lt;/a&gt; and execute your code in main (or its own thread).&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>