cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G030 - FLASH - Fail to use FLASH_Program_Fast

arthhh
Associate II

Hi!

I am using STMCube IDE and a STM32G030F6

I am trying to implement a code that writes variables to the flash. And I was able to make it work, with some limitations...

THIS CODE WORKS

union
  {
  uint8_t regs[6];
  uint64_t data;
  } mem;  

  uint64_t *my_pointer;
  my_pointer = (uint64_t *)0x08007000; // base address of page 14
  if(*my_pointer == 0xFFFFFFFFFFFFFFFF) // if the memory is blank
  {
  HAL_FLASH_Unlock();
  mem.regs[0] = 25;
  mem.regs[1] = 50;
  mem.regs[2] = 75;
  mem.regs[3] = 100;
  mem.regs[4] = 1;
  mem.regs[5] = 0;

  HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, 0x08007000, mem.data);
  HAL_FLASH_Lock();
  }

I run this code in the initialization of the board, the first time the program runs it will enter the if...

Instead of using

HAL_FLASH_Program(FLASH_TYPEPROGRAM_DOUBLEWORD...

 I'd like to use:

HAL_FLASH_Program(FLASH_TYPEPROGRAM_FAST...

But i am not able to make it work... it crashes all the time in the function:

static void FLASH_Program_Fast(uint32_t Address, uint32_t DataAddress);

What is the best way to write a series of variables in the flash? I plan to write more than 20 uint16_t...

 

1 REPLY 1
Jar_No
Associate

Same here. The Flash_Program_Fast keeps crashing.