**A Simple Circuit for RESET and nBOOT Control of STM32 micro-processors**
# Introduction
If you have ever made circuits for an STM32 micro-processor, you will have undoubtibly noticed that
you need *two* buttons for controlling it. First, you need a `RESET` control in order to restart the
processor. But you might also want to control the boot-mode via `BOOT0`, which can be selected to either boot from
the chip's internal flash memory, or else be booted in boot-loading mode. During development, you can upload
your program to the chip by utilizing the boot-loader.
This does however take up quite a bit of board-space. A typical solution looks like the following:
![Figure [vanilla]: Vanilla circuit.](vanilla-circuit.png)
As you can see, you will need one push-button for the reset, as well as a switch for the boot-mode.
# Reusing a single push button
We can use a single push button and some extra circuitry to implement *both* `RESET` and `BOOT0` inputs
to the processor. The idea is to make a "long" press (more than half a second) mean to reset into
boot-loader mode, and "short" press to just reset the chip. This can be done by using RC divider circuits,
an inverter and a Schmidt-triggered buffer.
It happens that a single chip implements three Schmidt-triggered inverters with a small footprint, thus reducing
the component count to 3 resistors, 2 capacitors and a single IC, the `74LVC3G14`.
![Figure [solution]: Solution.](solution.png)
In normal operation, when `SW2` is open, `MR` is brought high with a time-constant of `1.1 ms`.
The input `RST` signal will also be driven high, which means that we are *not* resetting the chip due to the
inverse logic. (At the same time, `U3C` will output logic `0`, discharging `C12`, so the initial state of
`BOOT0` is `0.0V`.)
When `SW2` is pressed, `MR` is brought to ground, discharging `C11` through `R2`. The time-constant is `0.1 ms`,
which is quite fast. This will put the chip in reset mode. At the same time, the output of `U3C` will go high,
charging the `C12` capacitor with a time constant of `1.0 s`.
If `SW2` is released quickly, this will not be enough time for `BOOT0` to go high. Since the boot-mode is selected
when the chip restarts, the STM32 will read the `BOOT0` signal as low, and hence boot into flash-memory. However,
if `SW2` is released after about `0.4 s`, then it will be read as high, meaning that it will boot into the boot-loader.
The `R1` resistor is chosen to make sure not too much power is lost when the button is pressed. At `3.3V`, the current
through `R1` is `0.33 mA`.
# Layout
The figure below shows the footprint of the components. Using 0603 components, and SSOP-8 package, it easily fits
within a `7.5 mm x 6.5 mm` space, a lot smaller than the typical `10 mm x 10 mm` LQFP package used for the STM32 chip
itself, and switches can be much larger than that.
![Figure [breadboard]: Breadboard.](breadboard.png)
# Conclusion
I used the design in an STM32L476 application and it works like a charm. I normally program the chip using
the SWD debugger probe, but the ability to also program the chip using the USB-port was a nice addition.
All you need to do is to connect the board via USB, hold the reset button for a while, and then run your upload script.
And of course, to rerun it, all you need to do is to tap the reset button.
When I want to debug the device, I hook up the SWD debugger using the JTAG connector, but when I just want to upload a
previously known-to-work program, it's much easier to use the USB-connector.