cancel
Showing results for 
Search instead for 
Did you mean: 

When data is deleted in Flash, this directly affects my GPIO pins.

FatihTaşt.
Associate II

I am working with STM32G030K6T6 MCU. In some cases I write and erase to flash memory. While writing there is no problem, while erasing some of my GPIOs go from HIGH to LOW momentarily. I see LED blinking momentarily. Erase function works fine but my general purpose peripheral is affected. My write and erase functions are almost the same as STM32Cube->Repository example. No change is observed in MCU power supply. Can you help me? Thanks.

4 REPLIES 4

@FatihTaşt. wrote:

My write and erase functions are almost the same as STM32Cube->Repository example. 


"almost" ?  :thinking_face:

So what, exactly, is different?

TDK
Guru

Probably going to need more detail here. Which pins are affected and at which point exactly within the code.

If you feel a post has answered your question, please click "Accept as Solution".
FatihTaşt.
Associate II

This happens when I call the HAL_FLASHEx_Erase() function and I get the message "Target not responding, retrying......" from St-Link for a short while. The LED I control on port B resets briefly.Also the ST-link SWD pins are probably affected by this situation.

FLASH_EraseInitTypeDef erase_init;
uint32_t page_error = 0;

/* Set page erase initialization structure */
erase_init.TypeErase = FLASH_TYPEERASE_PAGES;
erase_init.PageAddress = page_address;
erase_init.NbPages = page_count;

HAL_FLASH_Unlock();
/* Flash erase initialization */
if (HAL_FLASHEx_Erase(&erase_init, &page_error) != HAL_OK)
{
/* Error condition handling */
// Error_Handler();
}

HAL_FLASH_Lock();

 The error received is indicated;

Ekran görüntüsü 2024-07-30 165533.png