<?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>About the handler of &amp;quot;nRF52832&amp;quot;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69516/about-the-handler-of-nrf52832</link><description>Hello. 
 We are developing products using BLE modules. 
 The one used for that module was &amp;quot;nRF52832 (512kB Flash, 64kB RAM)&amp;quot;. 
 
 I would like to know 
 Question 1: 
 As a basic operation, I understand that various handlers are registered in Nordic&amp;#39;s</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Dec 2020 15:30:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69516/about-the-handler-of-nrf52832" /><item><title>RE: About the handler of "nRF52832"</title><link>https://devzone.nordicsemi.com/thread/286105?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 15:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:80950ff5-69f8-4343-9174-6aaedef02ceb</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;You welcome, I am happy to be of help.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I wish you the best of luck with your project &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About the handler of "nRF52832"</title><link>https://devzone.nordicsemi.com/thread/286001?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 10:08:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cac36cd-e169-4d19-800a-c2b5a99f2e05</guid><dc:creator>KURODA ELECTRIC</dc:creator><description>&lt;div class="oSioSc"&gt;
&lt;div id="tw-target"&gt;
&lt;div class="Vyy3r"&gt;&lt;span class="FTIxXb z1asCe XYTjwf"&gt;&lt;/span&gt;&lt;span id="tw-err-msg"&gt;&lt;/span&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Dear &lt;span style="background-color:#f4f7f8;color:#11171a;float:none;font-family:Helvetica,Arial,sans-serif;font-size:13.3px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Torbj&amp;oslash;rn&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="g9WsWb" id="kAz1tf"&gt;
&lt;div class="tw-ta-container hide-focus-ring tw-nfl" id="tw-target-text-container"&gt;
&lt;pre class="tw-data-text tw-text-large XcVN5d tw-ta" style="text-align:left;" id="tw-target-text" dir="ltr"&gt;&lt;span lang="en"&gt;Thank you for your teaching.

Thank you very much for helping me!&lt;/span&gt;&lt;/pre&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: About the handler of "nRF52832"</title><link>https://devzone.nordicsemi.com/thread/285669?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 14:47:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76531d47-809d-43a3-a607-9b175a5aeb48</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for the information, now the question is clear &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It is true that if you want to access the same buffer from the main context and from the Bluetooth event handler, you need some way to control this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;1) Flag method:&amp;nbsp;When the BLE event occurs you should not access the shared buffer directly, but set a flag that you can check in the main loop. Then you can check this flag in the main context and access the shared buffer safely.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;2) An alternative method is to use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___n_r_f___n_v_i_c___f_u_n_c_t_i_o_n_s.html?cp=4_7_3_1_2_9_2_1#gac3d990530890d81f388de7d507e170b8"&gt;sd_nvic_critical_region_enter()&lt;/a&gt; and sd_nvic_critical_region_exit() functions whenever you access the shared buffer in the main context. This will ensure that no BLE events are executed within this region.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would not recommend this method if the memory access in main takes a long time to execute, but small buffer copy operations should be fine.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About the handler of "nRF52832"</title><link>https://devzone.nordicsemi.com/thread/285495?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 05:08:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f499e3a3-ba14-4583-ba38-ed0396db73a0</guid><dc:creator>KURODA ELECTRIC</dc:creator><description>&lt;div class="T4LgNb"&gt;
&lt;div class="WFnNle"&gt;
&lt;div class="OlSOob"&gt;
&lt;div class="ccvoYb"&gt;
&lt;div class="AxqVh"&gt;
&lt;div class="OPPzxe"&gt;
&lt;div class="dePhmb"&gt;
&lt;div class="eyKpYb"&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Dear &lt;span style="background-color:#f4f7f8;color:#11171a;float:none;font-family:Helvetica,Arial,sans-serif;font-size:13.3px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Torbj&amp;oslash;rn&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Thank you for your reply below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt; Regarding Question 3, after the processing of the first event is completed I understand that events that occur later will be processed. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Regarding questions 1 and 2, I am sorry that the question is difficult to understand. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;We will change the question as follows. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Questions 1 and 2: Please refer to the attached typical case. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;The buffer is shared between main () and the event handler, While manipulating the buffer with main () I don&amp;#39;t want the event handler to manipulate the buffer. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;In that case, add a function like Mutex in a multithreaded program, or I think it is necessary to temporarily stop the occurrence of the event handler. How should we achieve the above? &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;hr /&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;uint8_t g_pucBuffer1[256];&lt;br /&gt;uint8_t g_pucBuffer2[256];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;static void sample_handler(void * p_context);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;int main(void)&lt;br /&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;// Initialization process omitted.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;while (1)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;// I don&amp;#39;t want the handler to rewrite the buffer until the following processing is completed.&lt;br /&gt;&amp;nbsp;&amp;nbsp;// I think we need an exclusion like Mutex in multithreading.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; memcpy(g_pucBuffer1, g_pucBuffer2, 256); &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;}&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="background-color:#ffffff;"&gt;void sample_handler(void * p_context)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;memset(g_pucBuffer2, 0xAA, 256);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;hr /&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class="J0lOec"&gt;&lt;span class="VIiyi" lang="en"&gt;&lt;span class="JLqJ4b"&gt;&lt;span&gt;Thank you for your cooperation.&lt;/span&gt;&lt;/span&gt;&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&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: About the handler of "nRF52832"</title><link>https://devzone.nordicsemi.com/thread/285216?ContentTypeID=1</link><pubDate>Wed, 16 Dec 2020 07:09:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fef8379d-a0f3-487a-9966-3c1ab81458ec</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
[quote user=""]As a basic operation, I understand that various handlers are registered in Nordic&amp;#39;s SoftDevice and are called back when an event occurs.[/quote]
&lt;p&gt;Correct. There is a system callback for handling system level events, such as flash write complete, and then there is a BLE callback for handling events related to the BLE stack.&amp;nbsp;&lt;/p&gt;
[quote user=""]Is it necessary to exclusively control this callback on the normal processing side when using a buffer common to our normal processing?[/quote]
&lt;p&gt;My apologies, but I am&amp;nbsp;not quite sure what you mean by this question. Can you try to rephrase the question?&lt;/p&gt;
[quote user=""]&lt;p&gt;&lt;span&gt;Question 3:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If another event occurs while processing the event handler, will the event handler that occurred later take precedence?&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Internally in the SoftDevice all events are added to an event queue, and they will be processed one after the other in the order they were generated.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In other words, if you are busy processing one event while the next one happens, the last event will only be processed after you are done processing the first.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Because events are processed in an interrupt context it is not recommended to perform very heavy or slow processing inside the event handler. If you need to run a lot of code as a result of a SoftDevice event it is recommended to use a flag or a scheduler to execute the processing in the main context.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>