STM32 Minimal System - Page 1
Forum section: electronics / general

author: newbie666
author_rank: Regular Contributor
timestamp: May 27, 2019, 08:35:04 pm
content: Hi there,I'm thinking about stepping up my microcontroller game and start designing chips on the various project boards I make instead resorting to bluepills / teensies. So my question is:what is the bare minimum of parts that STM32 needs to run and be programmed via JTAG? Do I need anything else than decoupling caps? Is this info somehow included in the datasheet? If so where would I be looking for it?Second question is what would you normally include when you design a board around a microcontroller? I'm looking for some tips here like "I always put a reset button" or "led to verify that uC is alive with a simple blinky". Please do share all the small things you learned over the years.As I've mentioned above, I've done some projects involving microcontrollers before but I always designed a board around one of the popular breakout boards so I have zero experience with designing pcbs for uCs.BTW I've mentioned STM32 because that's a processor I'm most familiar with and I have tools to program it.

author: capt bullshot
author_rank: Super Contributor
timestamp: May 27, 2019, 08:47:51 pm
content: Most STM32 run with decoupling caps and nothing else.You don't want JTAG anymore, a typical debug connector would consist of GND,VCC,SWD,SWCLK and RESET. You might want to add SWO. For the default pinout, look at the ST-Links attached to these nucleo 64 boards. Next would be a GND / RxD / TxD from an unused U(S)ART. Very useful for "printf" based debugging. An LED tied to a free GPIO is also useful. Bring out unused GPIO pins to a pin header, you may want to connect an oscilloscope as an aid for timing critical debugging - e.g. set that port bit at the very start of an interrupt routine and reset at the end to see its runtime behaviour on the scope. Have the option to use an external crystal, the frequency of the internal oscillators isn't always precise enough.Otherwise, I often include a CAN transceiver and a step-down switcher (to connect and supply from a CAN network).

author: thm_w
author_rank: Super Contributor
timestamp: May 27, 2019, 09:10:20 pm
content: You can get away with just decoupling caps and a 4 pin connector (3.3V Vcc, Gnd, SWD, SCLK) for debugging. But I would go with capt bullshot suggestions of adding a bit more than that.Could look at a bluepill schematic for some ideas:https://wiki.stm32duino.com/index.php?title=Blue_PillIt does depend a bit on which chip you plan to use, and what features (ie ADC).https://www.eevblog.com/forum/microcontrollers/stm32f4-minimal-circuit/

author: DDunfield
author_rank: Regular Contributor
timestamp: May 27, 2019, 10:06:04 pm
content: I like to put a header with VCC, GND, SWDIO and SWCLK which is the minimum you need for an ST-LINK debugger.I also like to put a header with VCC, GND, USART1-TXD, USART1-RXD, RESET and BOOT0 - USART1 gives you a console/debug interface, and also access to the on-board serial bootloader (on some STM32's you can only access the bootloader from USART1). I wrote a little program to automatically load the device serially. Much easier to if you need a customer to update a device in the field than trying to get them to use ST-LINK - you just give them a little USB-Serial adapter configured with the right header connector, driving RESET and BOOT0 from DTR and RTS. It is extra useful if you arrange the header so that you can connect a 3-wire serial and a separate Reset/BOOT button box independently.Or - if your device has at least one button connected to a GPIO, and you don't mind using active-high for the button, you can parallel BOOT0 with the GPIO the button connects to, and thus holding down the button while reset (or power-on) will activate the serial boot loader. In this case all you need to have is a simple 3-wire serial connection. Since BOOT0 is ignored after reset, the button works normally thereafter.If you're really short of pins, you can combine a Debug "blinky" LED with a "serial boot" button on a single GPIO pin (plus BOOT0) - you just need a resistor to limit current if you happen to poke the button after you have configured the pin as output.DavePS: To access the serial boot loader (at least on an STM32F103..) you will also need to have PB2/BOOT1 pulled low at reset.Refer to the ST document on the bootloader for the capabilities and requirements for other devices.

author: lucazader
author_rank: Regular Contributor
timestamp: May 27, 2019, 10:52:29 pm
content: All of the above are very good suggestions.I will also say the printf based uart is super useful. Also putting it on ROM bootloader comaptible pins is handy.I would also re-enforce break out extra pins to a header or at least solder-able test points, especially pins that can do analog.There are many times i ahvent done this and regretted it when the schematic was slightly wrongYou ARE going to make mistakes, the best of us do. So make your life easier by making it much easier to add bodge wires!Also add an area of exposed ground. You'll need more ground headers/ points to probe than you realise, always.Add a footprint for a crystal (with the appropriate caps) but dont populate it until you need it. For 95% of the times I used an stm the internal HSI clock is good enough.Maybe add a 32khz crystal option as well? The internal LSI on the st parts are super inaccurate. On some parts the frequency can vary between 25-40khz.

author: emece67
author_rank: Frequent Contributor
timestamp: May 27, 2019, 11:22:21 pm
content: .

author: mskeete
author_rank: Contributor
timestamp: May 28, 2019, 06:40:34 am
content: My first post after lurking for many monthsDecoupling caps6 pin SWD headerAt least one led for testing timer config and or "the code got this far" statusThere's been times I wished I had simple serial I/o to send debug messages but I've managed without it and learned to use eclipse better (breakpoints and examine variables)Breakpoints are a bit of a pain for real time stuff (simple audio project using the internal ADC/DAC)I played with STMStudio the other day and it worked rather well. Hoping that gets integrated into STMCubeIDE

author: richardman
author_rank: Frequent Contributor
timestamp: May 28, 2019, 09:04:08 am
content: Keep in mind that you can use ARM semihosting instead of UART based printf for "printf". So you can get printf with just the SWD. However, ST-LINK does not support Semihosting, so you will have to use something like the JLINK or Black Magic Probe etc.

author: techman-001
author_rank: Frequent Contributor
timestamp: May 28, 2019, 02:14:08 pm
content: Quote from: newbie666 on May 27, 2019, 08:35:04 pmI ran Forth on this home made STM32 board with just one decoupling cap, you can see it in the pic below, the wire soldered to the 32 pin QFN is 0.5mm in diameter. I talk to it with a $0.90 USB/3.3v dongle which also supplies the power and the terminal connection to my PC.It really needs a (replaceable) reset button as a Forth user resets the MCU about 1000 times every day while developingA power LED and a LED connected to PC-8 or PC-9 (like a discovery board) is handy but not essential as one can connect anything to the pins typically connected to most of the GPIOS on premade 'universal boards', and a SWD programmer can also be plugged into the relevant 3 pins when flashing is required..

author: newbie666
author_rank: Regular Contributor
timestamp: May 28, 2019, 02:21:38 pm
content: @techman-001: that's amazing and hilarious at the same time xDThanks a lot everyone, it looks like I'll make those my "defaults":1) SWD header for programming and printf logging2) One led3) Decoupling caps4) Extra GND points for probingI'm really amazed that that's it!

author: Siwastaja
author_rank: Super Contributor
timestamp: May 28, 2019, 03:47:37 pm
content: Good suggestions,For the UART header, do take a look at the reference manual section about the factory bootloader; don't bring out just any random UART, but make sure you bring out the correct pins so you can dual-purpose your header for reflashing the MCU through the factory bootloader, or use the same UART for your application as you wish. Add a pulldown resistor to the BOOT0 pin and bring the BOOT0 pin out to the header so you can select the factory bootloader easily by applying 3V3 or 5V to this pin during powerup. (This logic is true for most STM32 parts. Some might have BOOT1 pin or different logic level mappings to choose the memory area, do check this out.)Personally, I use the factory bootloader a lot, it does the trick so why not. Sometimes as my only means to program the device (until I add in-application flashing).

author: pigrew
author_rank: Frequent Contributor
timestamp: May 28, 2019, 05:46:21 pm
content: Each STM32 IC has a corresponding "Getting started with STM32xxxx Series hardware development" application note. These describe what external components are needed. For example, the STM32G0* hasAN5096. The document also says what to do with unused pins.As previously noted, the STM32s mostly just require decoupling capacitors at minimum.

author: techman-001
author_rank: Frequent Contributor
timestamp: May 28, 2019, 09:51:15 pm
content: Quote from: Siwastaja on May 28, 2019, 03:47:37 pmI totally agree and I should have mentioned this as well but I don't normally use the inbuilt factory bootloader myself preferring SWD. However the factory bootloader is fast and works like a charm.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 06, 2019, 11:14:00 pm
content: One of the most usefull things I make on almost any (development) PCB is a place to add a thick copper loop to the PCB to easily connect crocodile clips of my scope and DMM to the PCB GND.For the boards I build on perf board I also much prefere THT IC's or modules above SMD.When there is any doubt of a broken IC or module you can simply pull it out and replace it with another one.When designing PCB's though I mostly use as much SMD as anybody else. But size of me is rarely a big issue so I use 1206 resistors and capacitors a lot because I happen to have some ... 100.000 or so of them. (Recently also bought SMD booklets from Ali with 0805.I do not care much for bootloaders. Even with the odd "arduino UNO" clone board I sometimes use I usually start with connecting a programmer and erasing the bootloader with the first program written to it.I mostly use USBasp (for the AVR's) and ST-Link V2 (Clone) for the STM32.I realy dislike toggling buttons or weird key combinations on a development board just to have it enter a boot loader mode.By simply attaching the programmer I have lying around the programming process gets a lot more reliable, and can always be initiated by pushing a single button on my PC keyboard, which triggers a makefile target through whatever IDE I happen to be using at that time.