Skip to main content
Explorer
March 12, 2025
Solved

How to detect the RESET button on STM32L552E-EV

  • March 12, 2025
  • 7 replies
  • 1436 views

Hello,

I have a STM32L552E-EV, and I would like to know how to detect the RESET button ?

DYann1_0-1741794257271.png

Thank you for your helps.

    This topic has been closed for replies.
    Best answer by Andrew Neil

    Look at the board schematics:

    AndrewNeil_0-1741799547091.png

    You can see that, as @Chris21 said, the RESET button pulls the NRST signal low.

    The NRST signal is connected to the STM32's NRST pin:

    AndrewNeil_1-1741799640779.png

     

    So pressing the RESET button will cause a hardware reset of the STM32.

    So software can't directly detect the button being pressed.

    But you can detect the reason for a reset:

    AndrewNeil_2-1741799833917.png

    https://www.st.com/resource/en/reference_manual/rm0438-stm32l552xx-and-stm32l562xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf#page=327

     

    7 replies

    Graduate
    March 12, 2025

    The reset button pulls down the NRST pin, which is not the one you are showing. When the button is released, the CPU will start executing code from the Reset Handler.

    Super User
    March 12, 2025

    Look at the board schematics:

    AndrewNeil_0-1741799547091.png

    You can see that, as @Chris21 said, the RESET button pulls the NRST signal low.

    The NRST signal is connected to the STM32's NRST pin:

    AndrewNeil_1-1741799640779.png

     

    So pressing the RESET button will cause a hardware reset of the STM32.

    So software can't directly detect the button being pressed.

    But you can detect the reason for a reset:

    AndrewNeil_2-1741799833917.png

    https://www.st.com/resource/en/reference_manual/rm0438-stm32l552xx-and-stm32l562xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf#page=327

     

    DYann.1Author
    Explorer
    March 12, 2025

    Thank you,

    The button B4 is not the picture that I show before ? PB4.(PORT B, number 4). To detect a button press by interruption, we can always know in the callback when the user presses the button, Right ?

    For one of my programs I just need when the user presses the RESET button

     

    Graduate
    March 12, 2025

    There is a button (switch) on the board which is labeled RESET and has a black cap.  We have described what that button does.

    DYann.1Author
    Explorer
    March 12, 2025

    @Chris21 wrote:

    There is a button (switch) on the board which is labeled RESET and has a black cap.  We have described what that button does.


    Yes I know B4 and I can see on my board so ? My question is how to detect the pressing of this button via the program, but apparently it is impossible, it is strange ? Is it really impossible ?

    Graduate
    March 12, 2025

    PB4 is a microcontroller pin, not a button.  Do you have a button (switch) connected to PB4?

    DYann.1Author
    Explorer
    March 12, 2025

    @Chris21 wrote:

    PB4 is a microcontroller pin, not a button.  Do you have a button (switch) connected to PB4?


    Yes, I was mistaken but when I press the button, can't it be detected by software ?

     

    DYann1_0-1741810768963.png

     

    Super User
    March 12, 2025

    @DYann.1 wrote:


    Yes, I was mistaken but when I press the button, can't it be detected by software ?


    That's already been explained: that button is connected to the NRST pin.

    The NRST pin causes a hardware reset of the chip - so you cannot detect that in software.

    But, again, the software can detect the cause of a reset - as described earlier.

    Graduate
    March 12, 2025

    Following a reset (which has nothing to do with pin PB4 [NJTRST is not NRST]), the Reset Handler code executes, typically followed by SystemInit(), and then main(). Usually, if code at the start of main() is executed, a reset or power on has occurred.

    Graduate
    March 12, 2025

    I noticed that the schematic labels the reset button with "B4" as well as "RESET".

    Chris21_0-1741810430470.png

    That may have caused some confusion.  Again the button interacts with the NRST pin as described above.

    Graduate
    March 12, 2025

    NRST is not a GPIO pin.

    int main (void)
    { 
     [perhaps hardware initialization code]
     [perhaps HAL_Init();]
     
     printf("I've been reset!!!!");
     
     [other initialization code]
     
     while (1)
     {
     [do stuff]
     }
     }