cancel
Showing results for 
Search instead for 
Did you mean: 

Error 42004 when writing to data flash?

gendreau
Associate II
Posted on December 07, 2010 at 13:50

Error 42004 when writing to data flash?

3 REPLIES 3
brazov22
Associate II
Posted on May 17, 2011 at 15:11

Hi,

if your application needs a block (128 bytes) to be programmed very quickly (about 4 ms), you need to copy flash functions in RAM, as specified in FWLIB examples. Otherwise you can program a block from eeprom (without loading functions in RAM) writing consecutively 128 bytes without setting any FLASH->CR2 bit. In this latest case the time to program a block is about (128 x 4) ms.

P.S. In the firs case using FWLIB example remember to set in the linker TAB of STVD the E_W_ROUTs segment as specified in the attached picture.

brazov2

gendreau
Associate II
Posted on May 17, 2011 at 15:11

> you need to copy flash functions in RAM, as specified in FWLIB examples.

> P.S. In the firs case using FWLIB example remember to set in the linker TAB

> of STVD the E_W_ROUTs segment as specified in the attached picture.

Thanks brazov2,

For some reason I interpreted the documentation to mean that copying the flash write functions to RAM was only necessary when programming the application flash area, not the data flash. Now that I read that paragraph of PM0051 more carefully, this makes perfect sense. I will confirm if this works shortly.

-helyx

gendreau
Associate II
Posted on May 17, 2011 at 15:11

I have confirmed it. The problem was that I was writing to data flash from a function that was located in program flash.

The fix in my case (Raisonance compiler) was to add the ''inram'' keyword to the end of the function declaration:

void FLASH_ProgramBlock(u16 BlockNum, FLASH_MemType_TypeDef MemType, FLASH_ProgramMode_TypeDef ProgMode, u8 *Buffer) inram

{

    

...

}

Thank you so much! I was really pulling my hair out on that one.