write without Erase to the specified address with 0xffffffffffffffff value , in stm32g030 Family
Hello
I created a simple project in cubeMX, based on the STM32G030F6PX micro.
I'm going to write on the micro only once, at a specific address.
I defined a variable at the beginning of the sixth page and set it to 0xFFFFFFFFFFFFFFFFFUL.
uint64_t TestAddressVALUE = 0x001122334455667788UL;
const uint64_t TestAddress __attribute __ ((at (0x08003000))) = (uint64_t) (0xFFFFFFFFFFFFFFFFFUL);And then I write in that address by the following code.
HAL_FLASH_Unlock ();
HAL_FLASH_Program (FLASH_TYPEPROGRAM_DOUBLEWORD, ((uint32_t) (& TestAddress)), (uint64_t) (TestAddressVALUE));
HAL_FLASH_Lock ();When I program the micro with ST-Link, everything is ok and my code works well. But when I program it with same hex code, by usart, the write operation is not performed at the specified address and the following error occurs.
HAL_ERROR
HAL_FLASH_ERROR_PROGI followed this error and came to this guide.
Bit 3 PROGERR: Programming error
Set by hardware when a double-word address to be programmed contains a value different
from '0xFFFF FFFF' before programming, unless the data to write is '0x0000 0000'.
Cleared by writing 1But I already put the value 0xFFFFFFFFFFFFFFFFUL in the address.
I followed the FLASH-> SR register value in the FLASH_Program_DoubleWord function.
static void FLASH_Program_DoubleWord (uint32_t Address, uint64_t Data)
{
assert_param (IS_FLASH_PROGRAM_ADDRESS (Address));
/ * Set PG bit * /
SET_BIT (FLASH-> CR, FLASH_CR_PG);
/ * Program first word * /
* (uint32_t *) Address = (uint32_t) Data;
/ * Barrier to ensure programming is performed in 2 steps, in right order
(independently of compiler optimization behavior) * /
__ISB ();
printf ("\ r \ n 1FLASH-> SR =% 08X", FLASH-> SR);
/ * Program second word * /
* (uint32_t *) (Address + 4U) = (uint32_t) (Data >> 32U);
printf ("\ r \ n 2FLASH-> SR =% 08X", FLASH-> SR);
}Exactly after the ISB function, the value of FLASH-> CR is equal to 0x00040000, but after executing the code line
* (uint32_t *) (Address + 4U) = (uint32_t) (Data >> 32U);Its value changes to 0x00000008. That is, there is a problem with the second burn byte.
I wonder why this is not a problem with st-link and only with usart this problem occurs.
It is necessary to explain that:
If I erase the page before writing, I have no problem. But I cannot erase it. In the stm32f0 family, a memory cell with a value of 0xff could be written without need the erase.
Please help if you have an idea.
