<?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>Hardfault</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57780/hardfault</link><description>Hi. I just put this on my main code: uint32_t pg_size,* addr,pg_num, numero_guardado_memoria=0 ; pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE; pg_num = NRF_FICR-&amp;gt;CODESIZE - 1; addr= (uint32_t *)(pg_size * (pg_num+1)); if((uint32_t)*(addr)==&amp;#39;D&amp;#39;){ addr=(uint32_t *</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 21 Feb 2020 13:03:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57780/hardfault" /><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/235720?ContentTypeID=1</link><pubDate>Fri, 21 Feb 2020 13:03:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d06b4d3-8bb8-42c7-9089-bde2d91b6b1d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I do not immediately see anything wrong in this snippet. However,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You should always check return values. What does&amp;nbsp;sd_flash_write() return?&lt;/li&gt;
&lt;li&gt;I do not see how/when you try to read. You should make sure to wait for the write to complete before trying to read. That is signaled by the&amp;nbsp;NRF_EVT_FLASH_OPERATION_SUCCESS or&amp;nbsp;NRF_EVT_FLASH_OPERATION_ERROR event.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/235403?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2020 10:36:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acb9ac16-84cb-4e12-a2c0-7c6adca10f31</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Ok i did this after all the initializations:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;br /&gt; pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // Use last page in flash&lt;br /&gt; //--------------------------------- &lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num); &lt;br /&gt; uint32_t buffer[3]={1,2,3};&lt;br /&gt; sd_flash_page_erase(pg_num);&lt;br /&gt; nrf_delay_ms(50); &lt;br /&gt; sd_flash_write(addr,(uint32_t*)buffer,3);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;erasing the mem works perfect, but writing on it doesn&amp;#39;t make anything... just pass over it without write anything&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/235398?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2020 10:26:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28300a10-68fc-45ec-ad53-b3448cdc9ce7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Nasib"]It works for me also, but if before the memory writing and erasing i initialize the BLE, the GPIOTE, and the TIMERS, then is when the system stops...&amp;nbsp;[/quote]
&lt;p&gt;That is expected. You are not allowed to write to flash directly when the SoftDevice is active. In that case, you need to use the SoftDevice API to write to flash, or alternatively fstorage, which does this for you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/235383?ContentTypeID=1</link><pubDate>Thu, 20 Feb 2020 10:01:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8a33846-58d7-4497-8b40-6c58c8022318</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Ok i discovered what is happening.. but i dont know how to solve it.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;It works for me also, but if before the memory writing and erasing i initialize the BLE, the GPIOTE, and the TIMERS, then is when the system stops...&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Is there any shared resource or something ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234806?ContentTypeID=1</link><pubDate>Tue, 18 Feb 2020 08:27:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9084f06-2636-401c-9e21-e9532310af55</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Nasib"]Right?&amp;nbsp;[/quote]
&lt;p&gt;Yes.&lt;/p&gt;
&lt;p&gt;[quote user="Nasib"][/quote]&lt;/p&gt;
&lt;p&gt;And the sistem still freezing even in the flash_page_erase or in the flash_word_write (if i comment the erase function)....&lt;/p&gt;
&lt;p&gt;Debugging the code, just besore to erase, this page (firs word) is: 0xffffffff (so i guess the is no code there... )&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Odd. Your code works for me (with some minor cleanup). You can verify by putting this main.c file in&amp;nbsp; &amp;lt;SDK 12.3&amp;gt;\examples\peripheral\blinky\:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-cd6104a45ad6430181df1294e693e912/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Using a debugger (remember to turn off optimization) you can see that the code finishes all flash operations and runs to the main loop. Then I verified that the data had been written by dumping the flash (using &amp;quot;nrfjprog.exe --memrd 0 --n 0x40000 &amp;gt; flash_dump.txt&amp;quot;). As you can see in the attached file (&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-cd6104a45ad6430181df1294e693e912/flash_5F00_dump.txt"&gt;devzone.nordicsemi.com/.../flash_5F00_dump.txt&lt;/a&gt;), you have the expected data written to&amp;nbsp;0x0003F800 and&amp;nbsp;0x0003F400 (using a nRF51 device with 256 kB flash).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234733?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2020 16:30:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48556cc8-bbc1-4758-a6af-e906b6015cdd</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;So for saving (ie) two words, i have to :&lt;/p&gt;
&lt;p&gt;0) look for the last code position&lt;/p&gt;
&lt;p&gt;1) erase the next whole page after that possition&lt;br /&gt;&lt;br /&gt;2) write a word in the first position of that page&lt;br /&gt;&lt;br /&gt;3) jump a whole page&lt;/p&gt;
&lt;p&gt;4) erase that page&lt;/p&gt;
&lt;p&gt;5) write a word in the first possition of that page.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Right?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I DO THIS :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt; pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;br /&gt; pg_num = NRF_FICR-&amp;gt;CODESIZE-2; // Use last page in flash&lt;br /&gt; &lt;br /&gt;&lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num);&lt;br /&gt; flash_page_erase(addr);&amp;nbsp;&lt;br /&gt; patwr_32 = &amp;#39;D&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32);&amp;nbsp;&lt;br /&gt; nrf_delay_ms(10);&lt;/p&gt;
&lt;p&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;br /&gt; pg_num = NRF_FICR-&amp;gt;CODESIZE-3; // Use last page in flash&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num); &lt;br /&gt; flash_page_erase(addr);&amp;nbsp;&lt;br /&gt; patwr_32 = &amp;#39;X&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32);&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And the sistem still freezing even in the flash_page_erase or in the flash_word_write (if i comment the erase function)....&lt;/p&gt;
&lt;p&gt;Debugging the code, just besore to erase, this page (firs word) is: 0xffffffff (so i guess the is no code there... )&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234714?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2020 15:26:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21a1573a-c15e-48bd-a729-3108572c13b9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Nasib"]1) should i erase the existing&amp;nbsp;word&amp;nbsp;before to write a new one?&amp;nbsp;[/quote]
&lt;p&gt;Yes and no. Due to the nature of flash, writing can only change &amp;#39;1&amp;#39; to &amp;#39;0&amp;#39;. So you cannot overwrite existing data unless that is already erased, or just just want to turn more bits from &amp;#39;1&amp;#39; to zero. Also due to the nature of flash, you cannot erase single words, but only full pages. Erasing a flash page means making all words in that flash page all &amp;#39;1&amp;#39;s (0xFFFFFFFF).&lt;/p&gt;
[quote user="Nasib"]2) if the code ends in the X position , where can i storage data ? should i configure the keil to end short the code memory reservation?[/quote]
&lt;p&gt;You can store application data in any available flash that is not occupied by the application. If you do not have a bootloader and do not use FDS or similar (used by the peer manager if you use BLE bonding), then any space above the application end address is available. But make sure to stare with a page offset, so that you are able to erase it without erasing parts of the application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234702?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2020 15:14:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05afe9c3-e924-4d41-a0a5-aaf16dd34e2c</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Ok , i am going to implement the code with fstorage. But before to start i need to solve 2 concepts:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;1) should i erase the existing&amp;nbsp;word&amp;nbsp;before to write a new one?&amp;nbsp;&lt;br /&gt;2) if the code ends in the X position , where can i storage data ? should i configure the keil to end short the code memory reservation?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234444?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 14:14:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efcb2ecc-bb4c-48bd-87a7-a441c4575f7f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;flash_page_erase() you have implemented does not support non-page aligned addresses, which is what you provide as mentioned before. See register documentation for&amp;nbsp;ERASEPAGE:&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;Register for starting erase of a page in code area.&lt;/em&gt;&lt;/p&gt;
&lt;p style="padding-left:30px;"&gt;&lt;em&gt;The value is the address to the page to be erased (addresses of first word in page). Note that the erase must be enabled using CONFIG.WEN before the page can be erased. Attempts to erase pages that are outside the code area may result in undesirable behavior, e.g. the wrong page may be erased.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You need to have control over your addresses. I suggest you consider using &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_fstorage.html"&gt;fstorage &lt;/a&gt;instead, as that will handle the low-level complexities for you. Moreover, if you make mistakes like passing invalid addresses, you will get a sensible error code returned. In this case, you would have gotten a&amp;nbsp;NRF_ERROR_INVALID_ADDR returned from&amp;nbsp;nrf_fstorage_erase().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234428?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 13:48:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:106f0b07-5ffb-40d2-a21f-305499954875</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Hi Einar!&lt;br /&gt;&lt;br /&gt;These are the functions:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;static void flash_page_erase(uint32_t * page_address){&lt;br /&gt; // Turn on flash erase enable and wait until the NVMC is ready:&lt;br /&gt; NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;// Erase page:&lt;br /&gt; NRF_NVMC-&amp;gt;ERASEPAGE = (uint32_t)page_address;&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;// Turn off flash erase enable and wait until the NVMC is ready:&lt;br /&gt; NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;static void flash_word_write(uint32_t * address, uint32_t value){&lt;br /&gt; // Turn on flash write enable and wait until the NVMC is ready:&lt;br /&gt; NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;*address = value;&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;// Turn off flash write enable and wait until the NVMC is ready:&lt;br /&gt; NRF_NVMC-&amp;gt;CONFIG = (NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos);&lt;/p&gt;
&lt;p&gt;while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy)&lt;br /&gt; {&lt;br /&gt; // Do nothing.&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;how would you write just 4 words (32bits) in memory ??&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I just need to do this.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Which are the steps?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;__________________________________________________________&lt;br /&gt;&lt;br /&gt;Another aproach::&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;i do this in the main fuinction AND EVERYTHING WORKS OK:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;br /&gt; pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // Use last page in flash&lt;br /&gt; //--------------------------------- &lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num); &lt;br /&gt; //addr=(uint32_t *)0x5A801; &lt;br /&gt; &lt;br /&gt; if((uint32_t)*(addr)==&amp;#39;D&amp;#39;){ //renombro &lt;br /&gt; numero_guardado_memoria=(uint32_t)*(addr); &lt;br /&gt; } &lt;br /&gt; //----------------------------------------------&lt;br /&gt; //------GUARDO D------------------- &lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num)+1;&lt;br /&gt; flash_page_erase(addr); //borramos memoria&lt;br /&gt; patwr_32 = &amp;#39;D&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32); //guardamos D en la primera posici&amp;oacute;n despu&amp;eacute;s de la D&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt; &lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num)+1;&lt;br /&gt; flash_page_erase(addr); //borramos memoria&lt;br /&gt; patwr_32 = &amp;#39;D&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32); //guardamos D en la primera posici&amp;oacute;n despu&amp;eacute;s de la D&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BUT when i try to repeat this paragraph in another function , it crashes in erasing the memory&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;addr = (uint32_t *)(pg_size * pg_num)+1;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_page_erase(addr); //borramos memoria&lt;/span&gt;&lt;br /&gt;&lt;span&gt;patwr_32 = &amp;#39;D&amp;#39;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_word_write(addr, patwr_32); //guardamos D en la primera posici&amp;oacute;n despu&amp;eacute;s de la D&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrf_delay_ms(10);&lt;/span&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234414?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 13:09:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17eb8638-470b-4d71-8df5-71da22f9bcd1</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Remembering this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE; // 1024
pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // 256-1=255 (assuming you don&amp;#39;t have a device with small flash&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s look at your other code snippet (which you write fails):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;addr = (uint32_t *)(pg_size * pg_num)+1 ;
flash_page_erase(addr); 
patwr_32 = &amp;#39;D&amp;#39;;
flash_word_write(addr, patwr_32); 
nrf_delay_ms(10);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here you provide an address that is not the beginning of the flash page to flash_page_erase(). How does it handle that? How is flash_page_erase() implemented? Most likely you must provide the address to the first byte of the flash page. If so, you should remove the &amp;quot;+1&amp;quot; when calculating addr.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234388?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 12:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f767f86d-cbb2-4865-89eb-f8df510cb239</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Hi..&lt;br /&gt;&lt;br /&gt;The Rom1 conf (in keil) was: from 0x1b000 to 0x40000&lt;br /&gt;&lt;br /&gt;So i guess that memory was just for code. so i reduce it in keil conf to: 01b000 to 0x3f800&lt;br /&gt;&lt;br /&gt;Then i expected that those 2048 bytes were free to be used for other purposes...&amp;nbsp;&lt;br /&gt;&lt;br /&gt;As i understood from your reply, what i configure in keil is going to be the total amount of memory i can use in my device ?? (code + other purposes)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;What about the other problems?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I think the question is easy.. but i dont know how to solve it:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;With this everything is ok :&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // Use last page in flash&lt;/span&gt;&lt;br /&gt;&lt;span&gt;//---------------------------------&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;addr = (uint32_t *)(pg_size * pg_num);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_page_erase(addr);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;patwr_32 = &amp;#39;D&amp;#39;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_word_write(addr, patwr_32);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrf_delay_ms(10);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;But i dont know how to store other 32bit words without having hardfaults...&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234380?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 11:55:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c70c625c-a835-4842-b142-91e43bfb3516</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;[quote user="Nasib"][/quote]&lt;/p&gt;
&lt;p&gt;And finally i do this manually:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;addr=(uint32_t *)0x5A801;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That is&amp;nbsp;0x1B000 + 0x3F800 +1&lt;br /&gt;&lt;br /&gt;( I guess it is the next position in memory that the one dedicated for code )&amp;nbsp;&lt;br /&gt;&lt;br /&gt;and ALSO it gives me a hardfault&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This is clearly an invalid address (since it is higher than 256*1024=0x4000, so the hardfault is expected. You cannot use memory that does not exist.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234344?ContentTypeID=1</link><pubDate>Fri, 14 Feb 2020 09:06:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36f7d57d-c307-42b3-b7b4-f51dfaf0dee4</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Hi Dmitry, i try this:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;IROM1:&amp;nbsp;0x1B000 to&amp;nbsp;0x3F800 (2048 less than normally)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;And in the code:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;doing this, writing and reading is ok&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // Use last page in flash&lt;/span&gt;&lt;br /&gt;&lt;span&gt;//---------------------------------&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;addr = (uint32_t *)(pg_size * pg_num);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_page_erase(addr);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;patwr_32 = &amp;#39;D&amp;#39;;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;flash_word_write(addr, patwr_32);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;nrf_delay_ms(10);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;doing this&amp;nbsp;reading is ok:&amp;nbsp;&lt;br /&gt;&lt;br /&gt; pg_size = NRF_FICR-&amp;gt;CODEPAGESIZE;&lt;br /&gt; pg_num = NRF_FICR-&amp;gt;CODESIZE-1; // Use last page in flash&lt;br /&gt; //--------------------------------- &lt;br /&gt; addr = (uint32_t *)(pg_size * pg_num)+1; &lt;br /&gt; &lt;br /&gt; if((uint32_t)*(addr)==&amp;#39;D&amp;#39;){ //renombro &lt;br /&gt; numero_guardado_memoria=(uint32_t)*(addr); &lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Doing this it crashes in flash_page_erase:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;addr = (uint32_t *)(pg_size * pg_num)+1 ; &lt;br /&gt; flash_page_erase(addr);&amp;nbsp;&lt;br /&gt; patwr_32 = &amp;#39;D&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32);&amp;nbsp;&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt;&lt;br /&gt;And with this in word_write:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;addr = (uint32_t *)(pg_size * (pg_num+1)) ; &lt;br /&gt; flash_page_erase(addr);&amp;nbsp;&lt;br /&gt; patwr_32 = &amp;#39;D&amp;#39;; &lt;br /&gt; flash_word_write(addr, patwr_32);&lt;br /&gt; nrf_delay_ms(10);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;And finally i do this manually:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;addr=(uint32_t *)0x5A801;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That is&amp;nbsp;0x1B000 + 0x3F800 +1&lt;br /&gt;&lt;br /&gt;( I guess it is the next position in memory that the one dedicated for code )&amp;nbsp;&lt;br /&gt;&lt;br /&gt;and ALSO it gives me a hardfault&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234261?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 17:02:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abf0b9da-5f1c-4a2f-ac60-2edb68466417</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;You can read&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/nvmc.html?cp=4_2_0_10_0#concept_ghg_zdz_vr"&gt;documentation&lt;/a&gt;&amp;nbsp;about how flash memory works.&lt;/p&gt;
&lt;p&gt;Flash page size depends on chip: nrf51 - 1024 bytes, nrf52 - 4096 bytes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234255?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 16:26:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d42c85e-25de-47e6-a883-7d88e10e3bb7</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;Could you explain me a little bit what is a page and how big in it is ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thanks a lot Dmitry (really)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234252?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 16:13:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9567d7d-5ce7-4749-9187-f05c715cacd4</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Your flash is from address 0 to (NRF_FICR-&amp;gt;CODESIZE * NRF_FICR-&amp;gt;CODEPAGESIZE - 1), there&amp;#39;s no memory after it. If you need to allocate some area of flash for your data, you have to change&amp;nbsp;code size in your project settings (that is IROM1 in Keil) . Decrease this value, for example, by (pagesize&lt;span&gt;*2)&lt;/span&gt;, and you&amp;#39;ll have two pages for data at the end of flash: (pg_num-1) and (pg_num-2).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234244?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 15:47:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:369f7c35-e433-40ea-8da4-0b7be51298f1</guid><dc:creator>Nasib</dc:creator><description>&lt;p&gt;How can i acces to the first 32bits word after de code ? and the second one.. and so on ?&amp;nbsp;&lt;br /&gt;&amp;nbsp;&lt;br /&gt;I need to storage and read info from sensors to de flash..&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thanks a lot..&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hardfault</title><link>https://devzone.nordicsemi.com/thread/234242?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 15:41:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3711ef0-7ac2-46f8-8ad8-f7327e0cfd68</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;pg_size * (pg_num+1)&amp;nbsp; will point to a non-existing&amp;nbsp;byte right after your flash memory, it&amp;#39;s no wonder that you&amp;#39;re catching a hardfault..&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>