Two Dumb question ahead: Reset Pin and USB Powering - Page 1
Forum section: electronics / beginners

author: soFPG
author_rank: Frequent Contributor
timestamp: July 03, 2020, 04:10:55 pm
content: I am currently designing a PCB (schematic attached) with a STM8L051F3 on it (Datasheet:https://www.st.com/resource/en/datasheet/stm8l051f3.pdf).I would like to be able to reset the uC by a button press on the PCB. According to the recommended reset circuit (attached as an image) I should add a capacitor to prevent random resets through current on the connected pin.Is this correct? I thought adding a series capacitor would basically act like open wire after the capacitor is fully charged. How would the NRST-Pin be able to detect whether the button switches the signal level to GND?Second question: As you can see I would like to connect the uC via a CH340G to USB but on the other hand I also want to program with SWIM-pin. What I don't want is that the USB is powered from the programming device (ST-Link V2 probably) which supplies 5V.How can I prevent this? Is there an easy way to keep the uC plugged in as a USB-device (and therefore powered like one) but still be able to program it?Thank you for reading. If anything remained unclear, please don't hesitate to ask for more information.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 03, 2020, 04:13:54 pm
content: The datasheet recommendation is correct, your schematic isn't. The cap goes between the reset pin and ground just as in the datasheet. Here it filters noise; it's "parallel" to the reset pin, not in series with anything.Because NRST is active-low, you want the reset button to connect the NRST pin to ground, so that the reset is active whenever the button is pressed.The internal pull-up resistor keeps the reset high (non-active) when the button isn't pressed. You can add an external, smaller value pull-up if you want even more robustness against noise, but generally the cap does fine.

author: soFPG
author_rank: Frequent Contributor
timestamp: July 03, 2020, 04:20:37 pm
content: Thank you!Does this look correct now?

author: Siwastaja
author_rank: Super Contributor
timestamp: July 03, 2020, 04:21:46 pm
content: Yes (assuming you are indeed certain that switch pins 1 and 3 are connected together). Note that for easiest layout work, you may want to try swapping the cap to the (electrically same) NRST net instead, depends on placement.

author: rstofer
author_rank: Super Contributor
timestamp: July 03, 2020, 06:59:54 pm
content: At t=0 (power on), the voltage on the capacitor is likely 0V. It takes time for the internal pull-up resistor to charge the capacitor and this is known as "power on reset". That's why it is in parallel with the switch. Either can pull the pin to ground and cause a reset.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: July 04, 2020, 03:25:48 am
content: The cap on reset allows a bit of slow start and debounces the reset pin. Add a small resistor to help with slow start.Look at the schematic for the ESP32 dev kit for a circuit that let's you do what you're asking about for USB.

author: soFPG
author_rank: Frequent Contributor
timestamp: July 04, 2020, 08:39:41 am
content: QuoteIn series with the capacitor and the NRST-Pin? Sorry to ask this but why does this increase startup time?QuoteIs there something wrong with the way I plan to do it? This circuit looks similar to mine:https://en.ovcharov.me/2019/08/16/ch340g-programmer-for-esp8266-esp32/

author: Siwastaja
author_rank: Super Contributor
timestamp: July 04, 2020, 09:49:46 am
content: Quote from: soFPG on July 04, 2020, 08:39:41 amI'm confused as well regarding comment "Add a small resistor to help with slow start."Startup is delayed by the time constant caused by the capacitor being charged through the internal pull-up resistor. You can make it quicker by adding external pullup resistance in parallel with the internal - i.e. between NRST and Vcc, but you can only make total pullup R smaller because you can't remove the internal R. If you want to make the delaylongerinstead, increase the value of C.Much of such a passive RC delay isn't normally needed, though. Just use what the datasheet suggests. You likely have those 100nF capacitors for power pin bypassing laying around, reuse that BOM line.

author: soFPG
author_rank: Frequent Contributor
timestamp: July 04, 2020, 10:28:43 am
content: Thank you. I don't mind a "longer" startup time (quotation marks because we probably speak about time in the range of µs or ns ?)

author: Manul
author_rank: Super Contributor
timestamp: July 04, 2020, 12:24:42 pm
content: Also you may go with IC's like TLV803S. Proper reset with added benefit of brownout protection, because it is actually monitoring power supply voltage and does a reset based on that. It has open drain output, so it is compatible with manual reset button.

author: soFPG
author_rank: Frequent Contributor
timestamp: July 04, 2020, 03:58:24 pm
content: I don't know but I think this is overkill for my purposes.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 04, 2020, 05:11:37 pm
content: External brownout detector / reset ICs are mostly for special circuits consisting of custom (often discrete) logic, not just the MCU; or working around broken-by-design internal MCU implementations, now exceedingly rare. Or sometimes you want a special feature the integrated thing does not come with, say for example just a specific and more accurate detection voltage.Very unlikely you want one. Look at the MCU datasheet to see which kind of brown-out watchdog it provides for you.Some people are still traumatized by a few broken reset implementations and think duplicating the already-integrated circuitry with an external IC is a generally good idea. I don't blame them.

author: JustMeHere
author_rank: Frequent Contributor
timestamp: July 05, 2020, 03:44:28 am
content: See this. The first Google result happened to be for SThttps://www.google.com/url?sa=t&source=web&rct=j&url=https://www.st.com/resource/en/application_note/cd00059552-how-to-control-powerupreset-and-monitor-the-voltage-in-microprocessor-systems-using-st-reset-circuits-stmicroelectronics.pdf&ved=2ahUKEwjj2sOemLXqAhWiTd8KHUSJDxUQFjACegQIBhAB&usg=AOvVaw2BXmBMuXeUS7nV3kYjxV6D