cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S Write Flash Memory Issue

Hi world!
Associate III

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);

1 ACCEPTED SOLUTION

Accepted Solutions
Hi world!
Associate III

I fix problem. Problem is IAR debug.

View solution in original post

1 REPLY 1
Hi world!
Associate III

I fix problem. Problem is IAR debug.