<?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>k_sem_take failed UART interrupts Bluetooth</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/88060/k_sem_take-failed-uart-interrupts-bluetooth</link><description>Hello together, 
 
 Im currently doing my bachelor thesis and my task is to develop a user interface that can control a NRF52840 and write some parameters over UART. 
 Im able receive data that I sent from a python script, but if I want to start advertising</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 May 2022 14:28:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/88060/k_sem_take-failed-uart-interrupts-bluetooth" /><item><title>RE: k_sem_take failed UART interrupts Bluetooth</title><link>https://devzone.nordicsemi.com/thread/368659?ContentTypeID=1</link><pubDate>Thu, 19 May 2022 14:28:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45c5adab-7777-48ff-ac2a-930db7318474</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello&lt;/p&gt;
&lt;p&gt;Running BLE and UART in parallel is indeed a common issue, as BLE tasks need to run with high priority to comply with the strict timing requirements of the BLE specification, which can easily interfere with your UART operations. I would recommend that you use the UARTE peripheral, which has EasyDMA support that allows you to send/receive data directly through RAM while BLE uses the CPU:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fuarte.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fuarte.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/uarte/driver.html"&gt;http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrfx/drivers/uarte/driver.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This should solve your problem, and even gives you something cool to write about in your thesis.&lt;/p&gt;
&lt;p&gt;This other guy is technically correct that it&amp;#39;s good practice to keep blocking code out of your callback functions, and I&amp;#39;d recommend reading up on&amp;nbsp;&lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/synchronization/semaphores.html"&gt;semaphores&lt;/a&gt;&amp;nbsp;as a way to signal between threads, but I believe UARTE is a better solution to your issue.&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><item><title>RE: k_sem_take failed UART interrupts Bluetooth</title><link>https://devzone.nordicsemi.com/thread/368502?ContentTypeID=1</link><pubDate>Thu, 19 May 2022 06:27:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef71d749-9f39-49f3-99a9-93ea5eec8262</guid><dc:creator>PasN</dc:creator><description>&lt;p&gt;Hello Turbo J, thank you for your quick answer. I understand what you mean, but I don&amp;#39;t know how to realize it in code. Like I said, Im not experienced enough with Zephyr to find a solution by myself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: k_sem_take failed UART interrupts Bluetooth</title><link>https://devzone.nordicsemi.com/thread/368395?ContentTypeID=1</link><pubDate>Wed, 18 May 2022 13:48:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6492a246-2f29-416c-99e1-6f6061f9a101</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The callback from the uart function runs from an interrupt handler, which disallows a lot of OS-related functions. To keep stuff simple: You cannot call anything that &lt;em&gt;waits&lt;/em&gt; in an interrupt handler.&lt;/p&gt;
&lt;p&gt;Solution: Use one of the many ways that Zephyr provides to &lt;em&gt;communicate&lt;/em&gt; between the uart callback function and another thread/function/ work queue. There you can wait and use the bt_le_xxx() calls.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>