Page 1 of 1

Problems writing to Flash or to the Flash latch buffer

Posted: Tue Mar 01, 2016 2:30 pm
by mkrug

I tried to write my own flash programming routine. Basically I copied the example 'FLASH_PROGRAM_EXAMPLE'. However I always get a hard fault exception at the point where I write the data to the latch buffer. If one want to look at the corresponding line it is in flash_efc.c line 655 and simply says in a loop:
*p_aligned_dest++ = gs_ul_page_buffer[ul_idx];

I checked in disassembly mode and saw that copying the data from gs_ul_page_buffer to one of the registers works fine. It hard fault occurs at the moment that the data is written from the register to p_aligned_dest. This variable points to the flash address I want to program afterwards.

Unlocking and erasing the corresponding sector works fine. Also the above mentioned example works fine. So I guess it is not hardware problem.

Any idea?

Best Regards