<?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>BLE_NUS Service + FATFS storage on external flash</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66182/ble_nus-service-fatfs-storage-on-external-flash</link><description>Hello, guys! 
 We are using nRF52840 SoC together with the 15.3.0 version of SDK. 
 In our project, we basically want to combine BLE_NUS services together with the ability to store data on external QSPI flash formatted in FATFS. 
 The set of desired activities</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 22 Sep 2020 09:31:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66182/ble_nus-service-fatfs-storage-on-external-flash" /><item><title>RE: BLE_NUS Service + FATFS storage on external flash</title><link>https://devzone.nordicsemi.com/thread/270772?ContentTypeID=1</link><pubDate>Tue, 22 Sep 2020 09:31:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95608c7e-6883-4df8-869b-9ecda337d201</guid><dc:creator>bojan</dc:creator><description>&lt;p&gt;Makes sense, &lt;a href="https://devzone.nordicsemi.com/members/vibe"&gt;Vidar Berg&lt;/a&gt;! Will give it a try. &lt;/p&gt;
&lt;p&gt;Thanks for the great suggestions!&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE_NUS Service + FATFS storage on external flash</title><link>https://devzone.nordicsemi.com/thread/270760?ContentTypeID=1</link><pubDate>Tue, 22 Sep 2020 09:09:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c71a1fa6-ce30-4ca8-aefc-caaf03987ac2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Bojan,&lt;/p&gt;
&lt;p&gt;I guess this relates to interrupt priorities. The nus_data_handler() is inside the Softdevice &amp;#39;SD_EVT_IRQn&amp;#39; interrupt context with priority 6 which is the same as the default priority used by all of our peripheral drivers. In other words, I think it&amp;#39;s likely that your QSPI driver interrupts are getting blocked by the SD interrupt handler in this case.&lt;/p&gt;
&lt;p&gt;You could try to increase the interrupt priority of the QSPI driver and see if it helps. However, it&amp;#39;s generally considered good practice to avoid blocking calls inside interrupt handlers so I would instead suggest to deffer processing of these calls to the main context. One way you can do that is by setting a volatile flag inside the nus handler and do the processing from your main loop.&lt;/p&gt;
&lt;p&gt;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static volatile bool m_received_first_packet;
void nus_data_hanlder(..)
{
    ...
    if (&amp;lt;first data packet received&amp;gt;)
    {
        m_received_first_packet = true;
    }
    ..
    
}

int main(void)
{
    ...
    for(;;)
    {
        if (m_received_first_packet)
        {
            m_received_first_packet = false;
            open_apend();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>