<?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>Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108886/calculate-ram-when-getting-error-4-nrf_error_no_mem</link><description>Hi, 
 I&amp;#39;m writing an app that uses 3 BUTTONS and everything works fine. 
 When I decide to add a 4th BUTTON it fails and hangs, and I get ERROR 4 [NRF_ERROR_NO_MEM] After looking around, I found some explanations stating that we have to increase the FLASH_START</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 08 Mar 2024 10:24:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108886/calculate-ram-when-getting-error-4-nrf_error_no_mem" /><item><title>RE: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472903?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2024 10:24:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbdffbd9-d639-4358-8d31-d9b0e6d98966</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Steve&lt;/p&gt;
&lt;p&gt;To be fair I didn&amp;#39;t realize it would be that much work when I started &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f606.svg" title="Laughing"&gt;&amp;#x1f606;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I work more with the nRF Connect SDK these days, and keep forgetting how fiddly it can be to add modules and libraries in the nRF5 SDK (not to say the new SDK is perfect, but the act of adding libraries or building for different nRF devices is vastly improved).&amp;nbsp;&lt;/p&gt;
[quote user="Steve Jordi"]&lt;code&gt;&lt;span&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt; i = &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;; i &amp;lt; 1000&lt;/span&gt;&lt;span&gt;; i++) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &amp;quot;Thanks&amp;quot; &amp;lt;&amp;lt; &lt;/span&gt;&lt;span&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span&gt;}&lt;/span&gt;&lt;/code&gt;[/quote]
&lt;p&gt;Haha, you are very welcome &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: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472858?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2024 08:16:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0931266-b60a-4907-8976-b63a4428e5f2</guid><dc:creator>Steve Jordi</dc:creator><description>&lt;p&gt;Wow, you went the whole 9 yards. Thanks a lot for your efforts, I didn&amp;#39;t mean someone to spend so much time on this.&lt;br /&gt;Just downloaded your example and will check it against my implementation&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Again,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span class="javakeywordcolor"&gt;for&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span class="javakeywordcolor"&gt;int&lt;/span&gt;&lt;span&gt; i = &lt;/span&gt;&lt;span class="javanumbercolor"&gt;0&lt;/span&gt;&lt;span&gt;; i &amp;lt; 1000&lt;/span&gt;&lt;span&gt;; i++) {&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; cout &amp;lt;&amp;lt; &amp;quot;Thanks&amp;quot; &amp;lt;&amp;lt; &lt;/span&gt;&lt;span class="javastringcolor"&gt;&amp;quot;\n&amp;quot;&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;span&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472689?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2024 12:13:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22992219-1346-4f06-bc0b-50f0ee8ca6ef</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Steve&lt;/p&gt;
&lt;p&gt;In order to use the app_button library you need to have both BUTTON_ENABLED and BUTTON_HIGH_ACCURACY_ENABLED in your sdk_config.h file, but I would recommend just leaving the last one set to 0:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifndef BUTTON_ENABLED
#define BUTTON_ENABLED 1
#endif

// &amp;lt;q&amp;gt; BUTTON_HIGH_ACCURACY_ENABLED  - Enables GPIOTE high accuracy for buttons
 

#ifndef BUTTON_HIGH_ACCURACY_ENABLED
#define BUTTON_HIGH_ACCURACY_ENABLED 0
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I went through the exercise of adding the app_button library to the esb_ptx sample in nRF5 SDK v17.1.0. It was quite a bit of work, as various files, include folders and sdk_config.h entries had to be added, but I got it working in the end. I can easily assign up to 4 buttons without any problems:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/esb_5F00_ptx_5F00_323091.zip"&gt;devzone.nordicsemi.com/.../esb_5F00_ptx_5F00_323091.zip&lt;/a&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: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472324?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2024 19:26:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0c5df4a-1a88-40ca-b810-631da9634dad</guid><dc:creator>Steve Jordi</dc:creator><description>&lt;p&gt;Yes, the code here works because it has only 3 buttons.&lt;br /&gt;I have no traces of&amp;nbsp;&lt;span&gt;BUTTON_HIGH_ACCURACY_ENABLED in my sdk_config.&lt;br /&gt;I started from the ESB examples provided in the SDK as a template and I realize I&amp;#39;m using gpio only and I should probably use gpiote too, that may also be a reason my button_handler is never called...&lt;br /&gt;&lt;br /&gt;Should I add&amp;nbsp;BUTTON_HIGH_ACCURACY_ENABLED 1 ? To what achievement?&amp;nbsp;&lt;br /&gt;Thanks for your lights.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Steve&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472177?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2024 08:12:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a9c18a8-6cd6-4b52-8932-cc1c6d0c63ee</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Steve&lt;/p&gt;
&lt;p&gt;You said the problem happens when you add a 4th button, so I assume the configuration you sent me now is the one that works, since it only has 3 buttons?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What about the BUTTON_HIGH_ACCURACY_ENABLED parameter in sdk_config.h?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I just did a quick test on my own extending the button handling in the ble_app_blinky example to use 4 pins, and it works without any other changes required:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    //The array must be static because a pointer to it will be saved in the button handler module.
    static app_button_cfg_t buttons[] =
    {
        {LEDBUTTON_BUTTON, false, BUTTON_PULL, button_event_handler},
        {BSP_BUTTON_1, false, BUTTON_PULL, button_event_handler},
        {BSP_BUTTON_2, false, BUTTON_PULL, button_event_handler},
        {BSP_BUTTON_3, false, BUTTON_PULL, button_event_handler}
    };

    err_code = app_button_init(buttons, ARRAY_SIZE(buttons),
                               BUTTON_DETECTION_DELAY);
    APP_ERROR_CHECK(err_code);&lt;/pre&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: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/472094?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2024 16:27:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ae107f8-9cb5-43d5-99b9-831068b3c6d1</guid><dc:creator>Steve Jordi</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sure here is the my_buttons array (I&amp;#39;m in SDK17 and 14 as well, same behavior)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;code&gt;static app_button_cfg_t my_buttons[] =&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_BIND,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTONS_ACTIVE_STATE,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_PULL,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; my_button_handler&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;},&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_CLEAR,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTONS_ACTIVE_STATE,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_PULL,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; my_button_handler&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;},&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_RESET,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTONS_ACTIVE_STATE,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; BUTTON_PULL,&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; my_button_handler&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;}&lt;/code&gt;&lt;br /&gt;&lt;code&gt;};&lt;/code&gt;&lt;br /&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;Of course they&amp;#39;re used in the my_button_handler function&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;static void my_button_handler(uint8_t pin_no, uint8_t button_action)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;{&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;if (button_action)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;{&amp;nbsp;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; switch (pin_no)&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; case BUTTON_BIND:&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;...do somthing...&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;break;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;case BUTTON_CLEAR:&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;...do something else...&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;break;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;case BUTTON_RESET:&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;...do another thing...&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;break;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;default:&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;break;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; &lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&amp;nbsp; &amp;nbsp;}&lt;/code&gt;&lt;br /&gt;&lt;code&gt;}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And no I don&amp;#39;t use GPIOTE channels for anything else, as far as I know.&lt;/p&gt;
&lt;p&gt;Steve&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Calculate RAM when getting ERROR 4 [NRF_ERROR_NO_MEM]</title><link>https://devzone.nordicsemi.com/thread/471999?ContentTypeID=1</link><pubDate>Mon, 04 Mar 2024 12:03:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba71d8e5-851a-4fd0-823c-900cfd6122aa</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Steve&lt;/p&gt;
&lt;p&gt;If you are running out of application RAM you should get a linker error when building, rather than get the&amp;nbsp;&lt;span&gt;NRF_ERROR_NO_MEM error when trying to initialize a library.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Looking at the definition of the app_button_init(..) function one possible cause of the&amp;nbsp;NRF_ERROR_NO_MEM error would be if you have run out of GPIOTE IN channels, but you should have 8 of them available, so I wouldn&amp;#39;t expect you to run out of these when trying to initialize just 4 buttons. Are you using GPIOTE channels for anything else in your application?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Would you be able to share the definition of the my_buttons array with me so I can see how you are trying to initialize the button library?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you know if&amp;nbsp;BUTTON_HIGH_ACCURACY_ENABLED is enabled or not?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>