2019-07-07 12:23 AM
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
2019-07-07 07:40 AM
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!
2019-07-07 11:01 PM