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...

 

4 REPLIES 4
Jar_No
Associate

Same here. The Flash_Program_Fast keeps crashing.

 

XR.1
Senior

Anyone at ST that has just a little interest in helping its customers?

Pazzy
Visitor

I have encountered the same issue, the FLASH_TYPEPROGRAM_FAST method crashes the micro and even aborts the debugging session.

A workaround has been to wrap FLASH_TYPEPROGRAM_DOUBLEWORD in a function that behaves (takes in the same parameters) as FLASH_TYPEPROGRAM_FAST, which then executes as expected and without an issue.

TDK
Super User

Would guess the issue here is that code has not been placed properly in RAM leading to unacceptable delays during fast programming. The __RAM_FUNC macro needs some help.

If you feel a post has answered your question, please click "Accept as Solution".