AnsweredAssumed Answered

Flash memory write -> HardFault_Handler

Question asked by dzorcz on Apr 12, 2014
Latest reply on Apr 13, 2014 by Clive One
Hi everyone,

I have problem with writing to flash memory in my application. uC STM32F051C4

#define FLASH1 (*((uint32_t *)0x08001016))

then flash function:

void FLASHunlock(void)
     if (FLASH->CR &0x00000080)
          FLASH->KEYR = 0x45670123;
          FLASH->KEYR = 0xCDEF89AB;

void FLASHwrite(void)
     uint16_t z=0xF0F0;
     while(FLASH->SR & 0x00000001);
     FLASH->CR = 0x00000001;

     FLASH1 = z;              -> here program jumps to HardFault_Handler

     while (FLASH->SR & 0x00000001);

Any ideas? Flash is eriassed (everywhere FF FF)