‎2019-09-20 01:38 PM
how to erase or program using by st cube ide stm32f030k6t6 ? after I have program ic PA13 and PA14 set as input pin. now I can't erase or debug with stlink swd . please help thanks
‎2019-09-28 06:07 PM
32 KB Flash, 32x 1 KB pages
Shrink the memory described to the linker from 32 KB to 31 KB
The sector will be at 0x08007C00 .. 0x08007FFF
uint32_t Address = 0x08007C00;
uint32_t Data;
/* Variable used for Erase procedure*/
FLASH_EraseInitTypeDef EraseInitStruct;
// Erase
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
/* Erase the user Flash area ***********/
/* Fill EraseInit structure*/
EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.PageAddress = Address;
EraseInitStruct.NbPages = 1;
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
/*
Error occurred while page erase.
User can add here some code to deal with this error.
PageError will contain the faulty page and then to know the code error on this page,
user can call function 'HAL_FLASH_GetError()'
*/
Error_Handler();
}
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();
// Write
/* Unlock the Flash to enable the flash control register access *************/
HAL_FLASH_Unlock();
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Address, Data) != HAL_OK)
{
/* Error occurred while writing data in Flash memory.
User can add here some code to deal with this error */
Error_Handler();
}
/* Lock the Flash to disable the flash control register access (recommended
to protect the FLASH memory against possible unwanted operation) *********/
HAL_FLASH_Lock();
// Reading
Data = *((uint32_t *)Address;
‎2019-09-28 06:35 PM
many thanks
my dear Clive =)
‎2019-09-30 03:10 PM
dear Clive
I got 2 error
error (1).
error on line (if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
error (PageError' undeclared (first use in this function); did you mean 'perror'?)
error (2).line Data = *((uint32_t *)Address; Syntax error
‎2019-09-30 04:13 PM
uint32_t PageError = 0;
Data = *((uint32_t *)Address);
‎2019-09-30 05:46 PM
‎2019-10-14 03:27 PM
dear Clive
firstly many thanks your help.
‎2019-10-14 03:41 PM
Collect ALL your configuration information into a structure, including a sequence number, manage the data in a RAM copy and then journal that across the flash pages, selecting the last one as being valid on the read side, and then writing to the next available slot. When you've consumed the whole page, then you can erase and recover one of them.
‎2019-10-14 03:58 PM
dear Clive
is there any erase function to erase specific address line ? or some easy way ?
‎2019-10-14 04:07 PM
Minimum erase size is a 1KB page.
Journalling a structure isn't unduly complicated.
‎2019-10-14 04:30 PM
dear clive
I am very new just in this mcu programing field .start working with this just few month ago. so i don't know many .have to learn many thing .
now very small thing is complicated for some time.
if you will guid me how to start some code in ram. like last time very easy for me to understand everything erase function and program and read.
thanks