<?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>write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51129/write-flash-in-ble_central-ble_app_uart_c</link><description>chip: 52832 . sdk 12.3\examples\ble_central\ble_app_uart_c\pca10040\s132, 
 i use this example to scan ble advistisment, i want to write some date to flash, i use flash_word_write , the mcu would restart, i use sd_flash_write, the mcu not restart, but</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Aug 2019 11:47:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51129/write-flash-in-ble_central-ble_app_uart_c" /><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/206851?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2019 11:47:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6bf0c46f-959c-4c73-923a-a6c6ee74fd53</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Carey,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please let me correct that:&lt;/p&gt;
&lt;p&gt;In the SDK 12.3.0, we&amp;nbsp;use the Softdevice dispatcher for fetching the event instead of &lt;span&gt;sd_evt_get()&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;From ble_app_hrs example in 12.3.0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for dispatching a system event to interested modules.
 *
 * @details This function is called from the System event interrupt handler after a system
 *          event has been received.
 *
 * @param[in] sys_evt  System stack event.
 */
static void sys_evt_dispatch(uint32_t sys_evt)
{
    // Dispatch the system event to the fstorage module, where it will be
    // dispatched to the Flash Data Storage (FDS) module.
    fs_sys_event_handler(sys_evt);

    // Dispatch to the Advertising module last, since it will check if there are any
    // pending flash operations in fstorage. Let fstorage process system events first,
    // so that it can report correctly to the Advertising module.
    ble_advertising_on_sys_evt(sys_evt);
} &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and the dispatcher for SoC events is set up in ble_stack_init():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Notice that all SoC events are forwarded to the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.3.0%2Fgroup__fstorage.html&amp;amp;anchor=ga1fcde5d157fe6048ca55c0ff3d403f74"&gt;fs_sys_event_handler(sys_evt)&lt;/a&gt;&lt;strong&gt;;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Event forwarding from the SoftDevice is done via &lt;strong&gt;softdevice_handler.c &lt;/strong&gt;(under nRF5_SDK_12.3\components\softdevice\common\softdevice_handler).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/206479?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2019 03:40:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:218c0ca1-fa6f-401c-b526-cfb8048b209d</guid><dc:creator>Carey</dc:creator><description>&lt;p&gt;the&amp;nbsp;&lt;span&gt;Num_Page is 8,&amp;nbsp; and i havn&amp;#39;t found&amp;nbsp;NRF_SDH_DISPATCH_MODEL in my project. I use &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;sdk 12.3\examples\ble_central\ble_app_uart_c\pca10040&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/206079?ContentTypeID=1</link><pubDate>Mon, 26 Aug 2019 11:09:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0df8ed01-100b-4813-8d0e-e6a32db59fa4</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What is the value of Num_Page are you erasing?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What is the value of NRF_SDH_DISPATCH_MODEL in sdk_config.h?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205977?ContentTypeID=1</link><pubDate>Sat, 24 Aug 2019 13:51:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22c75426-4450-4c2d-b3b5-3ca2d00143d9</guid><dc:creator>Carey</dc:creator><description>&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1566654601108v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;when the code run to the&amp;nbsp;&lt;span&gt;sd_evt_get(), the MCU restart, if i do not kill&amp;nbsp;nrf_delay_ms(50), the MCU would restart while run&amp;nbsp;nrf_delay_ms.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205853?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 10:48:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d5786ca-1735-4bea-941e-ca809f4b10e6</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;&lt;span lang="en-US"&gt;Hi&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en-US"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span lang="en-US"&gt;Did you call sd_evt_get() and wait for &lt;/span&gt;&lt;span lang="en-US"&gt;the event&lt;/span&gt;&lt;span lang="zh-TW"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___n_r_f___s_o_c___e_n_u_m_s.html&amp;amp;anchor=gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;&lt;span lang="zh-TW"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS &lt;/span&gt;&lt;/a&gt;&lt;span lang="en-US"&gt;in the loop as this &lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/48074/sd_flash_page_erase-error-code-success-but-flash-erase-fail/190645#190645"&gt;&lt;span lang="en-US"&gt;post&lt;/span&gt;&lt;/a&gt;&lt;span lang="en-US"&gt;? &lt;/span&gt;&lt;/p&gt;
&lt;p lang="nb-NO"&gt;Could you post the code?&lt;/p&gt;
&lt;p lang="zh-TW"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p lang="zh-TW"&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205781?ContentTypeID=1</link><pubDate>Fri, 23 Aug 2019 08:10:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caa2e23e-d52a-4376-9616-6f1adac6d6b0</guid><dc:creator>Carey</dc:creator><description>&lt;p&gt;but if i run&amp;nbsp;&lt;span&gt;sd_evt_get(), the result is same as the&amp;nbsp;nrf_delay_ms:&amp;nbsp; the MCU would restart,&amp;nbsp; what&amp;#39;s prablem with it ?&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205272?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2019 10:56:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0205ec5c-aee0-454b-8f00-2862ed664797</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi Carey,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When sd_flash_page_erase() returns NRF_SUCCESS, that only means that the erase request was successfully submitted to the SoftDevice. It does _not_ mean that the erase operation has actually been completed yet. When the erase operation completes, the SoftDevice will generate an event interrupt, and you must call sd_evt_get() to consume it. Please see this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/48074/sd_flash_page_erase-error-code-success-but-flash-erase-fail/190645#190645"&gt;post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span lang="en-US"&gt;Therefore, rather than using a fixed delay, I would recommend you to wait for the event&lt;/span&gt;&lt;span lang="zh-TW"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___n_r_f___s_o_c___e_n_u_m_s.html&amp;amp;anchor=gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;&lt;span lang="zh-TW"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/span&gt;&lt;/a&gt;&lt;span lang="en-US"&gt;, telling that the operation was successfully completed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;In addition, it is also good practice to check the returned error code when calling a function.&lt;/p&gt;
&lt;p&gt;&lt;span lang="en-US"&gt;Please see the documentation of the&lt;/span&gt;&lt;span lang="zh-TW"&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html&amp;amp;anchor=ga9c93dd94a138ad8b5ed3693ea38ffb3e"&gt;&lt;span lang="zh-TW"&gt;sd_flash_page_erase&lt;/span&gt;&lt;/a&gt;&lt;span lang="en-US"&gt;() function. You will get one of the following events&amp;nbsp;following the function call:&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___n_r_f___s_o_c___e_n_u_m_s.html&amp;amp;anchor=gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;&lt;span lang="en-US"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/span&gt;&lt;/a&gt;&lt;span lang="zh-TW"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="en-US"&gt;- The command was successfully completed.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v3.0.0%2Fgroup___n_r_f___s_o_c___e_n_u_m_s.html&amp;amp;anchor=gga2a3d2f55035ee3173aff0c05465fb648a7c0083f76ab9ee6e75369776526d584d"&gt;&lt;span lang="en-US"&gt;NRF_EVT_FLASH_OPERATION_ERROR&lt;/span&gt;&lt;/a&gt;&lt;span lang="zh-TW"&gt;&amp;nbsp;&lt;/span&gt;&lt;span lang="en-US"&gt;- The command could not be started.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205116?ContentTypeID=1</link><pubDate>Tue, 20 Aug 2019 15:54:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f21cafb3-22b3-416f-a19d-1a4650bcc0dc</guid><dc:creator>Carey</dc:creator><description>&lt;p&gt;err_code = sd_flash_page_erase((uint32_t)(120));&lt;br /&gt; APP_ERROR_CHECK(err_code); &lt;br /&gt; nrf_delay_ms(50);&lt;/p&gt;
&lt;p&gt;this is my code , the err_code return 0, but when it run to the&amp;nbsp;&lt;span&gt;nrf_delay_ms, the MCU restart. why?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/205086?ContentTypeID=1</link><pubDate>Tue, 20 Aug 2019 14:21:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdb25e19-c230-44e5-a1fc-2f2bc3cdd58d</guid><dc:creator>Carey</dc:creator><description>&lt;p&gt;OK, now i use&amp;nbsp;&lt;span&gt;(sd_flash_page_erase/sd_flash_write).&amp;nbsp; can you give me some example for how to use this&amp;nbsp;function?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: write flash in ble_central\ble_app_uart_c</title><link>https://devzone.nordicsemi.com/thread/204787?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 13:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df59cb04-b77e-4024-9133-7a55038730d0</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;flash_word_write() typically tries to access the NVMC registers directly, but you shouldn&amp;#39;t do that if you are running a SoftDevice.&amp;nbsp;When the SoftDevice is enabled, the SoftDevice API for accessing flash should be used (sd_flash_page_erase/sd_flash_write).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;Note: for writing and handling data storage in flash, the libraries&lt;a href="http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v12.3.0%2Flib_fds.html&amp;amp;cp=4_0_6_3_37"&gt;&lt;span&gt; nRF5 SDK v12.3.0: Flash Data Storage&lt;/span&gt;&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;and&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a title="Software Development Kit" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v12.3.0/lib_fstorage.html?resultof=%22%46%6c%61%73%68%22%20%22%66%6c%61%73%68%22%20%22%53%74%6f%72%61%67%65%22%20%22%73%74%6f%72%61%67%22%20"&gt;nRF5 SDK v12.3.0: Experimental: Flash Storage&lt;/a&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;are there to make it easier.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda H.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>