cancel
Showing results for 
Search instead for 
Did you mean: 

How can I programe E2PROM using word mode?

cgh21
Associate II
Posted on May 28, 2012 at 02:47

I tried to use the firmware lib to program it ,but failed.

FLASH_Unlock(FLASH_MEMTYPE_DATA);

  

  for(i = 0; i < DataLeng; i=i+4)

  {

   FLASH_ProgramWord(StartAddr + i,(*(u32*)pBuf));

   pBuf= pBuf+4;;

   FLASH_WaitForLastOperation(FLASH_MEMTYPE_DATA);

  }

FLASH_Lock(FLASH_MEMTYPE_DATA);

But when I use program_byte, it sucess. I just want to save time because I need to programe 23 byte at sequence address one time. Thanks!

ChrisChen
3 REPLIES 3
konay61
Associate II
Posted on May 28, 2012 at 15:17

Hi Chris,

It's just because of the mistake of the firmware code, check the FLASH_ProgramWord() function in stm8l15x_flash.c then correct the Address variable type to uint32_t. After all, hope it will be working properly.

cgh21
Associate II
Posted on June 02, 2012 at 09:00

Thanks for your reply,Now it's ok.

Thanks very much.

cgha

cgh21
Associate II
Posted on June 02, 2012 at 09:46

But it's very strange, because when I use the logic analyzer to measure the programe time, it's as long as byte programe. It takes about 187ms to write 7 words. So I think uncomment the

//FLASH->NCR2 &= (u8)(~FLASH_NCR2_NWPRG);  will not enter word programe mode,but still use byte programe mode ?

Why?

ChrisChen