Skip to main content
Visitor II
July 25, 2019
Solved

STM8S Write Flash Memory Issue

  • July 25, 2019
  • 1 reply
  • 1075 views

Hi guys,

I want to write data to the flash memory of the Stm8s003f3p6 processor. I can read / write to this processor's eeprom. But I can read the flash memory, but I can't write it. I write my codes with "IAR Embedded Workbench for STM8". I check the address I wrote in Debug mode, but I see that no data is written. I guess there's no way I haven't tried.

Here are the codes I wrote:

FLASH_PUKR = 0x56;
 FLASH_PUKR = 0xAE;
 while (!(FLASH_IAPSR & (1 << FLASH_IAPSR_PUL))){}
 
 FLASH_CR2 = 1 << FLASH_CR2_PRG;
 FLASH_NCR2 = (uint8_t) ~(1 << FLASH_NCR2_NPRG);
 
 pct = *(uint32_t *)(0x8000);
 
 (*(uint8_t*)(0x9000)) = 0x21;
 MSA_Delay(20);

    This topic has been closed for replies.
    Best answer by Hi world!

    I fix problem. Problem is IAR debug.

    1 reply

    Hi world!AuthorAnswer
    Visitor II
    July 26, 2019

    I fix problem. Problem is IAR debug.