Author Topic: STM32 Minimal System  (Read 5142 times)

0 Members and 1 Guest are viewing this topic.

Offline newbie666Topic starter

  • Regular Contributor
  • *
  • Posts: 73
STM32 Minimal System
« on: May 27, 2019, 08:35:04 pm »
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.
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: STM32 Minimal System
« Reply #1 on: May 27, 2019, 08:47:51 pm »
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).
Safety devices hinder evolution
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6570
  • Country: ca
  • Non-expert
Re: STM32 Minimal System
« Reply #2 on: May 27, 2019, 09:10:20 pm »
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_Pill

It 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/
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline DDunfield

  • Regular Contributor
  • *
  • Posts: 173
  • Country: ca
Re: STM32 Minimal System
« Reply #3 on: May 27, 2019, 10:06:04 pm »

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.

Dave

PS: 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.
 

Offline lucazader

  • Regular Contributor
  • *
  • Posts: 221
  • Country: au
Re: STM32 Minimal System
« Reply #4 on: May 27, 2019, 10:52:29 pm »
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 wrong
You 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.
 

Offline emece67

  • Frequent Contributor
  • **
  • !
  • Posts: 614
  • Country: 00
Re: STM32 Minimal System
« Reply #5 on: May 27, 2019, 11:22:21 pm »
.
« Last Edit: August 19, 2022, 02:22:39 pm by emece67 »
 

Offline mskeete

  • Contributor
  • Posts: 33
  • Country: gb
Re: STM32 Minimal System
« Reply #6 on: May 28, 2019, 06:40:34 am »
My first post after lurking for many months :)

Decoupling caps
6 pin SWD header
At least one led for testing timer config and or "the code got this far" status

There'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
 

Offline richardman

  • Frequent Contributor
  • **
  • Posts: 427
  • Country: us
Re: STM32 Minimal System
« Reply #7 on: May 28, 2019, 09:04:08 am »
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.
// richard http://imagecraft.com/
JumpStart C++ for Cortex (compiler/IDE/debugger): the fastest easiest way to get productive on Cortex-M.
Smart.IO: phone App for embedded systems with no app or wireless coding
 
The following users thanked this post: newbie666

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: STM32 Minimal System
« Reply #8 on: May 28, 2019, 02:14:08 pm »
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.

I 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 developing :)

A 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..
« Last Edit: May 28, 2019, 02:55:10 pm by techman-001 »
 
The following users thanked this post: newbie666

Offline newbie666Topic starter

  • Regular Contributor
  • *
  • Posts: 73
Re: STM32 Minimal System
« Reply #9 on: May 28, 2019, 02:21:38 pm »
@techman-001: that's amazing and hilarious at the same time xD

Thanks a lot everyone, it looks like I'll make those my "defaults":

1) SWD header for programming and printf logging
2) One led
3) Decoupling caps
4) Extra GND points for probing

I'm really amazed that that's it!
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 8237
  • Country: fi
Re: STM32 Minimal System
« Reply #10 on: May 28, 2019, 03:47:37 pm »
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).
 

Offline pigrew

  • Frequent Contributor
  • **
  • Posts: 680
  • Country: us
Re: STM32 Minimal System
« Reply #11 on: May 28, 2019, 05:46:21 pm »
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* has AN5096. The document also says what to do with unused pins.

As previously noted, the STM32s mostly just require decoupling capacitors at minimum.
 
The following users thanked this post: nAyPDJ

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: STM32 Minimal System
« Reply #12 on: May 28, 2019, 09:51:15 pm »
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).

I 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.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3447
  • Country: nl
Re: STM32 Minimal System
« Reply #13 on: June 06, 2019, 11:14:00 pm »
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.
« Last Edit: June 07, 2019, 12:10:18 am by Doctorandus_P »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf