<?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>Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54278/hi-i-want-to-write-some-data-to-flash-sdk12-3-use-fstorage-the-stack-failed-to-generate-system-events</link><description>I have added &amp;#39;sys_evt_dispatch&amp;#39; to the stack, but the callback function is still not called</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Nov 2019 08:04:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54278/hi-i-want-to-write-some-data-to-flash-sdk12-3-use-fstorage-the-stack-failed-to-generate-system-events" /><item><title>RE: Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/thread/219816?ContentTypeID=1</link><pubDate>Wed, 13 Nov 2019 08:04:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81a67995-690b-4f72-8b0d-b833ef68cb81</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;If you&amp;#39;re using the debugger to debug the application, can you halt the CPU after the flash write to make sure the program is not stuck in a loop somewhere? Also, maybe place a breakpoint in&amp;nbsp;sys_evt_dispatch() to confirm it&amp;#39;s not being reached.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It should not be necessary to change the interrupt priorities.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/thread/219813?ContentTypeID=1</link><pubDate>Wed, 13 Nov 2019 07:57:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc9ef95b-bf0f-4812-a747-9d869c85b7ac</guid><dc:creator>loser</dc:creator><description>&lt;p&gt;Thanks for your reply. I called it in the serial interrupt event, and now I changed it to the main loop. A flag is given in the serial port interrupt. The main loop detects the flag call&amp;nbsp;&lt;span&gt;m_flash_write().&lt;/span&gt;However, there is still no callback for the softdevice system events.Do I need to change the priority of the function?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/thread/219805?ContentTypeID=1</link><pubDate>Wed, 13 Nov 2019 07:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d3efc67b-118e-44fc-adf9-8481bc733762</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Looks like you have registered the handler correctly. But the while loop you have at the end of m_flash_write() will become blocking if you&amp;#39;re calling it from an interrupt with equal or higher priority than the Softdevice system events. Could that maybe explain the problem, or are you using m_flash_write() only in main context (not in an interrupt)? I suggest testing without the while loop if you&amp;#39;re unsure.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/thread/219781?ContentTypeID=1</link><pubDate>Wed, 13 Nov 2019 01:45:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08fa65b8-333a-4fdc-9e3f-ca78161c8336</guid><dc:creator>loser</dc:creator><description>&lt;p&gt;Hello, thank you for your reply. I used J_link online debugging. It&amp;#39;s part of my code&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void fs_evt_handler(fs_evt_t const * const evt, fs_ret_t result)
{
     if( (evt-&amp;gt;id == FS_EVT_STORE) &amp;amp;&amp;amp; (result == FS_SUCCESS) )
     {
          store_flag = 0;
     }
     else if( (evt-&amp;gt;id == FS_EVT_ERASE) &amp;amp;&amp;amp; (result == FS_SUCCESS) )
     {
          erase_flag = 0;
     }
     else if (result != NRF_SUCCESS) 
     {
				printf(&amp;quot;flash ERASE or STORE error\r\n&amp;quot;);
     }
}

FS_REGISTER_CFG(fs_config_t fs_config) =
{
		.callback  = fs_evt_handler,
		.num_pages = 1,             
		.priority  = 0xFE          
};

void m_flash_write(uint32_t const * const m_datas)
{
      fs_ret_t ret;
      erase_flag=1;
      ret = fs_erase(&amp;amp;fs_config, address_of_page(0), 1,NULL);
      if (ret != FS_SUCCESS)
      {
	//	 NRF_LOG_INFO(&amp;quot;fs_erase error\r\n&amp;quot;);
                 printf(&amp;quot;fs_erase error\r\n&amp;quot;);
		 printf(&amp;quot;err_code is:%d\r\n&amp;quot;,ret);
      }
      else
      {
		//printf(&amp;quot;fs_erase FS_SUCCESS\r\n&amp;quot;);
		//NRF_LOG_INFO(&amp;quot;fs_erase FS_SUCCESS\r\n&amp;quot;);
				fs_flag=1;
       }
        while(erase_flag == 1) 
				{ power_manage(); }
		if( fs_flag==1)
		{

        store_flag=1;
				fs_flag=0;
			ret = fs_store(&amp;amp;fs_config, fs_config.p_start_addr, m_datas,16,NULL);
			if (ret != FS_SUCCESS)
			{
		//  NRF_LOG_INFO(&amp;quot;fs_store error\r\n&amp;quot;);
				//printf(&amp;quot;fs_store error\r\n&amp;quot;);
				printf(&amp;quot;err code is:%d\r\n&amp;quot;,ret);
			}
			else
			{
		//NRF_LOG_INFO(&amp;quot;fs_store FS_SUCCESS\r\n&amp;quot;);
	  	 //printf(&amp;quot;fs_store FS_SUCCESS\r\n&amp;quot;);
			}
		}
	while(store_flag == 1) { power_manage(); }
}

static void sys_evt_dispatch(uint32_t sys_evt)
{
    fs_sys_event_handler(sys_evt);
}

static void ble_stack_init(void)
{
    uint32_t err_code;

    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&amp;amp;clock_lf_cfg, NULL);

    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);

    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);

    // Enable BLE stack.
#if (NRF_SD_BLE_API_VERSION == 3)
    ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
#endif
    err_code = softdevice_enable(&amp;amp;ble_enable_params);
    APP_ERROR_CHECK(err_code);

    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
		err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);

}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi, I want to write some data to flash.  SDK12.3, use FSTORAGE.The stack failed to generate system events .</title><link>https://devzone.nordicsemi.com/thread/219690?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2019 13:46:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56c1320d-bde6-474c-881c-8d249a57e302</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you registering the callback through&amp;nbsp;softdevice_sys_evt_handler_set() in ble_stack_init() as the other examples do it? In that case, please try to \&amp;nbsp;describe how you&amp;nbsp;verify that the callback is not invoked on SD SoC events.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>