Skip to main content
Explorer II
December 29, 2025
Question

STM32G070 software reset issue

  • December 29, 2025
  • 4 replies
  • 157 views

I was doing reset through SPI command and expected results are not happening.

 

this is the line i was expecting to reset the MCU

SCB->AIRCR = (NVIC_AIRCR_VECTKEY | (SCB->AIRCR & (0x700)) | (1 << NVIC_SYSRESETREQ));


where

#define NVIC_AIRCR_VECTKEY (0x05FA << 16)

#define NVIC_SYSRESETREQ 2

also my watchdog is running and expected to reset the system.
code snippet

 
FLASH_Unlock();
FLASH_ErasePage(0x08013000);
FLASH_ProgramWord(0x08013000, (uint64_t)0x0000000000000000ULL);
FLASH_Lock();

FLASH_Unlock();
FLASH_ErasePage(0x08013008);
FLASH_Lock();

SCB->AIRCR = (NVIC_AIRCR_VECTKEY | (SCB->AIRCR & (0x700)) | (1 << NVIC_SYSRESETREQ));
__DSB();

while (1);

 


Edited to apply proper source code formatting - please see How to insert source code for future reference.

    This topic has been closed for replies.

    4 replies

    Super User
    December 29, 2025

    Please give some more details - see: How to write your question to maximize your chances to find a solution

     


    @aravindpv wrote:

    I was doing reset through SPI command and expected results are not happening..


    So what, exactly, were you expecting to happen ?

    What, exactly, is actually happening ?

    What investigation/testing/debugging have you done to find the issue?

     


    @aravindpv wrote:

    this is the line i was expecting to reset the MCU.


    Is that line ever executed?

    Does it work without all the Flash stuff?

    Without the SPI?

    aravindpvAuthor
    Explorer II
    December 29, 2025

    i was running a bootloader + main app setup on mcu where i expecting a particular command over SPI to capture one of my else condition and which is properly triggering. And on that condition i have added a reset line like mentioned above which is not happening or code executing but stuck at somewhere that kind of result I am getting. Actually my plan was to reset the mcu and set to start from 0x08000000 were my bootloader lies.

    Super User
    December 29, 2025

    You didn't answer whether your reset line is ever getting executed?

     


    @aravindpv wrote:

     i have added a reset line like mentioned above .


    What do you mean, "like" ?

     

    Why is that line doing a read-modify-write on SCB->AIRCR ?

    Shouldn't it be just a write?

     

    Technical Moderator
    December 29, 2025

    Hello,

    Why complicate things to yourself? and why simply you don't use HAL_NVIC_SystemReset() to reset your MCU? You're already using HAL with the flash based on your shared code!

    Super User
    December 29, 2025

    If HAL_NVIC_SystemReset doesn't reset the chip perhaps you have NRST tied high. Can't think of any other reason for it not working.

    > But after reset, the RPi no longer sees the slave at 0x30

    So it is resetting just not doing what you expect after reset?

    Super User
    December 30, 2025

    This looks like AI generated code with the comments. Maybe stick to the working HAL implementations to modify flash.