cancel
Showing results for 
Search instead for 
Did you mean: 

problem with EEPROM block erase/programming on stm8l152r8

HIran
Associate

Dear Sir/Madam,

I have a problem with EEPROM block erase/programming on stm8l152r8 part number.

As I understood, EEPROM block erase/programming must be executed from RAM.

You have a tutorial included 4 steps as I attached you its picture.

I do all the steps correctly but compiler show me error in step 3 (changing linker file lnkstm8l152r8.icf).

Please find attached picture of my error and steps.

My condition:

1-      Software: IAR Embedded Workbench for STM8 version 3.10

2-      Part Number: stm8l152r8

Would you please help me to solving this problem?

Kind Regards,

Hamed

2 REPLIES 2
S.Ma
Principal

Dug some STM32L151 older code, Maybe will give some clues?

#define MCU_EEPSIZE 8
#define NB_OF_RETRIALS	0
#include "stm8l15x_flash.h" // manipulate mcu built-in EEPROM area
void MCU_EepromWriteBlock (u16 Adr, u8* ptr, u8 Count) 
{
	u8 i;
	u8 RetryCount = NB_OF_RETRIALS+1;
	if((Adr+Count)>(MCU_EEPSIZE*128))
		TrapError;
		
	if(Count==0)
		TrapError;
 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// unlock the write access of the data flash
  /*Define FLASH programming time*/
  FLASH_SetProgrammingTime(FLASH_ProgramTime_Standard);
 
  /* Unlock flash Data memory */
  FLASH_Unlock(FLASH_MemType_Data);
 
  /* Wait until Data EEPROM area unlocked flag is set*/
  while (FLASH_GetFlagStatus(FLASH_FLAG_DUL) == RESET)
  {};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
	for(i=0;i<Count;i++)
	{
		FLASH_ProgramByte(FLASH_OPERATION_STARTADDRESS+Adr+i, ptr[i]);
	
		if(FLASH_ReadByte(FLASH_OPERATION_STARTADDRESS+Adr+i)!=ptr[i])
			NOPs(1); // error!
	}
	
	// all bytes programmed
	FLASH_Lock(FLASH_MemType_Data); // lock and protect
 
  /* Wait until Data EEPROM area unlocked flag is reset*/
  while (FLASH_GetFlagStatus(FLASH_FLAG_DUL) == SET)
  {};
 
}                          
 

Good luck!

Dear HD139139 <> , Thank you for your email and your help. The method that you suggest me is in fact byte programming instead of block programming and it take long time to do for 16 blocks.(16 block=2048 byte ; 2048*6ms=12288ms time for erase &program). Please be noted I don’t have this much time, and need block programming for faster operation, but your tutorial for block programming(4 steps) don’t work correctly. Do you have any idea? Kind Regards, Hamed