STM32 Circuit Help - Page 1
Forum section: electronics / general

author: itsrealfast
author_rank: Contributor
timestamp: February 29, 2016, 02:00:50 pm
content: Hi I am new to the using STM32 microcontrollers and wanted some help regarding the minimal requirements. The processor part number is STM32F302R8T6.Attached is a schematic I did after lots of reading and viewing other examples. Device is USB powered I would appreciate some feedback to see if I am on the right track.Thanks

author: DroneBuster
author_rank: Contributor
timestamp: March 01, 2016, 08:31:17 am
content: I don't know if you are planning to use UART bootloader, but if you are add jumper to 3.3V from BOOT0.Power circuit example is in DATASHEET page 54. It's only missing 4.7uF capacitor1uF capacitor should be on VDDA. On VBAT you can add 0.1uFI usually pull up NRST pin but it got internal pull up

author: dgtl
author_rank: Regular Contributor
timestamp: March 01, 2016, 09:14:18 pm
content: 1) SWO is usually not needed (unless your debug adapter supports real-time trace and you need it). If you need the pin for other purposes, take it away.2) ARM has a standard pinout for SWD (new .05inch and old .1inch headers). Avoid re-inventing the wheel. Sadly, the st-link debugger does not come with the new connector cable, so make your own or source it elsewhere.3) You might want to make the usb pull-up resistor switchable. When releasing this resistor, the host detects disconnection. This might be needed if you can not answer as soon as the power is plugged in and the host starts to enumerate the device. If you make your own bootloader, you may need to disconnect when switching between bootloader and app etc. When adding a BOOT0 jumper, add a jumper to bridge this transistor, too (internal bootloader needs this resistor).4) If you are using internal bootloader (BOOT0 pin), pay attention to the default state of BOOT1 pin. The internal bootloader can be used to (re)program the chip via USB, so you do not need any extra HW (not even a debugger) to flash the boards. See AN2606!5) It is useful to bring out an usart to a pin header just for debugging. Sometimes you need a place to send debug output to. Plug in an usb to ttl-serial converter as you need it; having the pads on the board does not cost anything.6) See the STM app-note for external oscillator design (AN2867). Sometimes you may need a series resistor, so better add a R0 inline.

author: langwadt
author_rank: Super Contributor
timestamp: March 01, 2016, 09:31:06 pm
content: Quote from: itsrealfast on February 29, 2016, 02:00:50 pmwhy not stay with the standard st-link pinout? you have swapped VCC and GND

author: itsrealfast
author_rank: Contributor
timestamp: March 02, 2016, 07:36:09 pm
content: Quote from: DroneBuster on March 01, 2016, 08:31:17 am- I am not using any sort of bootloader at the moment. I would like to toggle the booloader over the USB instead of jumping the BOOT0 pin. Any special circuit needed to do this? Or is it only in software? I believe my firmware is bug free but for further updates I wouldn't mind having this feature. Any easy ways to implement this?- I will add the 4.7uF cap- So your saying to remove the L1 inductor and use a 1uF cap? And change the cap for VBAT to 0.1uF?- Is it safe to leave NRST the way it is?I have to fit this all on a 1.5 x 1 inch PCB. There are more parts on the schematic but I removed them just to isolate the STM32 circuit.Thanks again for your help

author: itsrealfast
author_rank: Contributor
timestamp: March 02, 2016, 07:50:40 pm
content: Quote from: dgtl on March 01, 2016, 09:14:18 pm1. I just thought it was apart of the programming pins. I can leave it there.2. Im building a fixture that will test a panel of boards so no need for a cable3. Can you please elaborate a little more on making it switching. Can you modify my schematic? Like I said before I know very little about how this should all work and dont want to make boards and they not work4. I will review AN2606 if no hardware mods is required that would be great!5. I wish I had room on the PCB to add this. This all has to fit on a 1.5 x 1 inch PCB. There are more parts on the schematic but I removed them just to isolate the STM32 circuit.6. Well I'm running the external oscillator on a dev board and it didn't require a series resistor.Thanks again for your help

author: Kilrah
author_rank: Unknown
timestamp: March 02, 2016, 07:53:02 pm
content: On a product I worked on we tied USB VBUS to BOOT0, so that if the USB cable is plugged while the device is off it starts in DFU mode without the need for jumper/button shenanigans.May or may not be appropriate for your application, probably not since you say it's supposed to be USB-powered (but not whether USB is the sole power source or just an option).

author: itsrealfast
author_rank: Contributor
timestamp: March 02, 2016, 07:58:57 pm
content: Quote from: langwadt on March 01, 2016, 09:31:06 pmThey are swapped to match the USB connector. This way on one side of the PCB i can have the USB and Programming header for testing and programming. A fixture will be made to program and test a panel. So sharing the GND was the easiest. See attached pic.

author: ale500
author_rank: Frequent Contributor
timestamp: March 03, 2016, 05:46:50 am
content: Decoupling caps should be placed as close to the uC as possible. Avoid those long thin traces, Just connect the VDD pin to one end of the cap and the other end to the ground plane. The GND pin also to the ground plane.

author: dgtl
author_rank: Regular Contributor
timestamp: March 05, 2016, 09:35:35 pm
content: Quote from: itsrealfast on March 02, 2016, 07:50:40 pmThe pull-up resistor is detected by the usb host and the host uses it as a presence signal. Both data pins have pull-down resistors on host side and the device pulls one or both of them up with a bit stronger resistor. When the data is sent, the drivers have much lower impedance and overdrive both resistors. The actual resistor placement (d+, d- or both) tells the host, what speed it needs to talk. The STM32 supports only low speed, so don't change that.If you add a transistor between the 3.3V and the resistor, you can make the device disappear. Sometimes you need that. 1) if your intialization code takes too much time, the host may time out before you are ready. You can work around this by starting the usb earlier, but it is not always an option. Also, some usb stacks may need main loop to be operational, so initializing slow peripherals while polling USB handler gets more difficult. In this case, you can switch on the transistor only after you are ready. 2) Restarts. You may need to restart the uc. The host does not know, that the uc has restarted and problems happen. It is better to disconnect the usb before restarting. 3) bootloaders and other re-enumeration issues. Sometimes, you need your own bootloader in front of your own application. For example, encrypted fw updates. If the bootloader speaks usb, then you need to disconnect the usb when bootloader finishes and app starts. If the bootloader does not speak usb, the resistor shall be switched off so that the host would not detect an error (windows "this device has malfunctioned" errors etc).For very simple devices, that have the USB always ready for the host, the resistor may always be present. Or if the usb is only connected for fw updates and other not frequent maintenance operations and you just ignore the problems and tell the user to try again if something fails.There are a lot of examples how to switch the pullup resistor. Some do it with one transistor, some use two (as the default state of gpio is pullup, you may want to have default-on or default-off depending on your solution). For examplehttps://www.olimex.com/Products/ARM/ST/STM32-H103/resources/STM32-H103-sch.gifThe same goes for most of the uc-s (but some have the resistors integrated, ie STM32F2). Other uc vendors have same information, iehttp://www.nxp.com/documents/application_note/AN11392.pdf