Skip to main content
Visitor II
July 29, 2024
Question

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

  • July 29, 2024
  • 3 replies
  • 1162 views

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.

    This topic has been closed for replies.

    3 replies

    Super User
    July 29, 2024

    @FatihTaşt. wrote:

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


    "almost" ?  :thinking_face:

    So what, exactly, is different?

    Super User
    July 29, 2024

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

    Visitor II
    July 29, 2024

    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

    Super User
    July 30, 2024