AnsweredAssumed Answered

STM8L EEPROM Block Programming

Question asked by lama rowiv on Jun 4, 2018

Hello

I'm use STM8L151G6
I'm trying use block programming as below:

 

//Unlock EEPROM memory
FLASH_Unlock(FLASH_MemType_Data);
while (FLASH_GetFlagStatus(FLASH_FLAG_DUL) == RESET);

FLASH_ProgramBlock(0, FLASH_MemType_Data, FLASH_ProgramMode_Standard, buffer);
while(FLASH_GetFlagStatus(FLASH_FLAG_HVOFF) == RESET);

  But cpu always stops inside  FLASH_ProgramBlock function, between instructions :

/* Standard programming mode */
FLASH->CR2 |= FLASH_CR2_PRG;

and

/* Copy data bytes from RAM to FLASH memory */
for (Count = 0; Count < FLASH_BLOCK_SIZE; Count++)
{
#if defined (STM8L15X_MD) || defined (STM8L15X_MDP)
*((PointerAttr uint8_t*) (uint16_t)startaddress + Count) = ((uint8_t)(Buffer[Count]));
#elif defined (STM8L15X_HD)
*((PointerAttr uint8_t*) (uint32_t)startaddress + Count) = ((uint8_t)(Buffer[Count]));
#endif
}

Therefore, I ask for help.

Outcomes