STM32F4 Minimal circuit - Page 1
Forum section: electronics / general

author: roli
author_rank: Regular Contributor
timestamp: July 05, 2014, 06:12:22 pm
content: Hi there!The project that I am working on is now finally coming to an end. Well at least the hardware parts are set and ready to go. And now I need to build a PCB to support everything. And of course one of the main things on there is the micro. I am currently using the STM32F4 discovery board that has the 100 pin STM32F407VGT on board. Since this basically has everything that I need I decided to simply use that to keep it simple.Problem is that I have never built a PCB for ARM MCU before. All my previous projects used (arduino compatible) ATMega MCUs which are really simple to use since you practically don't need anything. I know that ARMs are a bit more complex so that's why I am asking for help.For now I need a basic circuit that uses internal oscillators and needs as little hardware as possible (but will still work reliably). And I want it to be programmable using the SWD connector. Using different forums and the original datasheet I've come up with the circuit in the attachment.Is this OK or do I need anything else? The dataheet mentions a 4.7uF capacitor on one of the power lines but I am not sure if this means that I need a 100nF capacitor and a 4.7uF one or just the 4.7uF. I am also not entirely sure about the VREF+ capacitor either.What else do I need if I want to use the internal RTC? Probably something connected to the VBAT pin? The datasheet mentions a power switch but I don't get how that's supposed to work.

author: andyturk
author_rank: Frequent Contributor
timestamp: July 05, 2014, 07:03:29 pm
content: You want 100n decoupling caps near each VDD and then one 4u7 *somewhere*. Just put it next to one of the other caps where you have space on the board. You didn't say whether you're going to use any of the analog features of the chip, but it's a good idea to assume you will someday. The analog reference should probably be tied to VDD (you said this was a simple board), so it'll need to be decoupled too.To use SWD, you need to bring out SWDIO, SWCLK and nRST (plus VDD and GND). You have to connect your VDD to the debugger's VDD line, but your circuit needs to supply its own power. The debug header on your discovery board has six pins, but you don't really need the last one.For STM32, you *must* tie the BOOT0 pin to a stable logic level in order to have the chip reset correctly. Just connect it to GND and the mcu will boot from flash.The chip has RC oscillators that can generate the high speed system clock as well as a lower speed clock for the RTC. They aren't very accurate though, so if you actually care about "real time", you'll need a 32kHz crystal. Load capacitance is important, and ST has an application note somewhere that tells you how to pick a crystal that'll work and what capacitors you'll need to go with it.If your board is going to be USB powered (or some other non-battery source), treat VBAT as a power pin. Tie it to VDD and decouple to ground. If you want the RTC to run while the rest of the chip is powered down, then you'll have to do a little more work.Since you're going to the trouble to build a board, why not build in a way to power it too? Add a USB connector and a 3.3V LDO and you're pretty much there.EDIT: Attached is a what I used in a project last year. The mcu was a STM32F405 in a 64-pin package.

author: dannyf
author_rank: Super Contributor
timestamp: July 05, 2014, 08:16:36 pm
content: The absolute minimalist board consists just the mcu + a wire out of BOOT0: downloading (as well as debugging) can be done via ISP.If you are doing anything fairly sensitive on analog, I would separate Vref / AVDD from VDD: a small inductor would be good enough.QuoteA battery?I typically put a small serial resistor (22-47ohm) just in case I accidentally put power on the trace.

author: roli
author_rank: Regular Contributor
timestamp: July 05, 2014, 09:06:56 pm
content: Well absolute minimalist still includes capacitors as far as I know.I don't really need analog devices for this application - maybe just to read an LDR but even that is still to be decided.The thing will be powered through a 5V USB and I will include a 3.3V regulator - it just isn't implemented in the schematic yet.I've gone through the application notes for the RTC but I still don't know how to power the thing. I need an RTC to keep the time when I disconnect the main power (power loss). I know that I need a battery but I am not sure if anything else. The datasheet states:QuoteThat "through power switch" is what is giving me trouble. Or is really just as simple as whacking in the external crystal, two capacitors and a coin battery? I've read that the battery power only works for the LSE so obviously using the LSI is out of the question.The attachment has an updated schematic.

author: sfiber
author_rank: Regular Contributor
timestamp: July 05, 2014, 09:18:42 pm
content: I think that s the one of the hardest part of the arm.project.if you dont find any help,maybe you sould mail to st

author: andyturk
author_rank: Frequent Contributor
timestamp: July 05, 2014, 09:40:50 pm
content: Quote from: roli on July 05, 2014, 09:06:56 pmThe RTC is powered from VBAT, so the switch--if there is one--is turning off power to the VDD pins.Give some thought to what you want to happen when there's USB power, but no battery. I seem to remember that the chip will work OK if all the VDD are powered, but VBAT is *not*. It's probably worth seeing what the datasheet says for that situation.Another issue is the range of voltage on the VBAT pin. If you're using a non-rechargeable cell, then it'll start at whatever the nominal voltage is and go down. If you plan to recharge that battery via USB, most likely it'll be a LiPo and the charging voltage for the battery will be higher than what the VBAT pin can handle.

author: roli
author_rank: Regular Contributor
timestamp: July 06, 2014, 12:00:35 pm
content: That makes sense. At least I think so.According to the datasheet:QuoteIf I understand this correctly than it really is just as simple as whacking in a battery/supercap.I don't want a rechargeable battery in there. All I need is for the RTC to stay powered in case of a power loss and that is it.

author: dannyf
author_rank: Super Contributor
timestamp: July 06, 2014, 01:27:58 pm
content: For most of the modern chips, an absolute minimal circuit really consists of the chip itself - it has internal oscillator, onboard ROM/RAM, and the cpu. So it is done.As you add requirements, what's "minimal" gets expanded to include more and more stuff.

author: roli
author_rank: Regular Contributor
timestamp: July 07, 2014, 01:17:19 pm
content: Just the chip without those caps there would most probably not work. At least that's what I've seen while searching around. Although it does depend a bit on luck.When I am building a PCB I usually start with a minimum then build around that to get what I need/want. I have no problems with other circuitry, the only problem is the main MCU since I am not used to ARM chips.

author: Legit-Design
author_rank: Frequent Contributor
timestamp: July 07, 2014, 01:33:32 pm
content: http://rusefi.com/forum/viewtopic.php?f=4&t=381http://rusefi.com/forum/viewtopic.php?f=4&t=381Minimal pin compatible STM32F4 board fully open source.You can always have placement for extra caps and then just not solder them, the other way around is harder. Maybe include few zero ohm resistors where necessary.Reasons they did this:Quote

author: dannyf
author_rank: Super Contributor
timestamp: July 07, 2014, 02:52:11 pm
content: -Just the chip without those caps there would most probably not work-next time when you build a board, don't fit the caps and try to see if you can make it work.that way, you will know for sure.

author: Legit-Design
author_rank: Frequent Contributor
timestamp: July 07, 2014, 03:04:04 pm
content: Use your fingers as caps, I remember Jeri Ellsworth told in one interview how to worked a treat.

author: roli
author_rank: Regular Contributor
timestamp: July 07, 2014, 08:59:18 pm
content: @Legit-Design: Thank you very much for this. This is really what I needed here. And it even includes an RTC battery & crystal. Basically everything that I needed for my minimal design.QuoteDo I need to? The manufacturer tells us that they need to be there. So I will treat that as good enough reason to put them there. They won't hurt anyone if they are there. I've had a circuit where interrupts were being triggered when someone turned on the lights in the room or a hair dryer somewhere else in the house. Adding two capacitors to that circuit solved the problem. Were those capacitors needed? No. But they sure did make things better.

author: Legit-Design
author_rank: Frequent Contributor
timestamp: July 07, 2014, 09:21:36 pm
content: Quote from: roli on July 07, 2014, 08:59:18 pmBe sure to read the whole thread for problems/solutions, and if you fix something or make it better please share.

author: gxti
author_rank: Frequent Contributor
timestamp: July 07, 2014, 10:36:00 pm
content: VBAT works fine if you connect it directly to a coin cell or supercap. When VDD is on everything will run from VDD, when VDD is off then the LSE will run from VBAT. Of course that means that if you remove the battery it will still work fine so long as power is applied.

author: Jeroen3
author_rank: Super Contributor
timestamp: July 08, 2014, 03:29:32 pm
content: QuoteThis is tricky, where competitors can also run LSI from Vbat, STM32F4's do not.Refer to ARM to know the swd header pinout.http://infocenter.arm.com/help/topic/com.arm.doc.faqs/attached/13634/cortex_debug_connectors.pdfOr you can use the (5/6pin) st-link header. But using that for production might be an issue due to the lack of polarity shrouding.

author: sfiber
author_rank: Regular Contributor
timestamp: July 19, 2014, 08:46:06 am
content: actually I do like stm32f4 discovery board but it is a development board and there are lots of things to use,develop.But this can be cause some problems like pin offset voltages.When you want to use any of the adc pins without looking at to schematics,you can meet some problems easily.Some of the adc pins are connected to sensors and even if the sensors are out of use it's pins have a little voltage on its,like 200mv.

author: Ribster
author_rank: Frequent Contributor
timestamp: July 23, 2014, 11:12:38 am
content: You are right sfiber. What i kinda dislike is that there are already components connected to the chip. I've had some problems with my UART1.. When you have that, it's not always apparent and can lead to some headscratching..

author: roli
author_rank: Regular Contributor
timestamp: July 24, 2014, 05:11:19 pm
content: Well I have received my PCBs yesterday and have actually soldered one together. It is working as planned!Well everything except RTC with LSE. This may be a software issue though. It works fine when it is on but resets when I pull the power (battery of course is installed). If I use LSI instead, the clock doesn't reset even after the power is pulled (but doesn't increment because LSI isn't battery powered). But I hope it really is just a small software issue somewhere.Thanks very much for all your help!

author: Ribster
author_rank: Frequent Contributor
timestamp: December 22, 2014, 01:40:17 am
content: Did you get it working ?Can you share some pics / code ?Thanks

author: Jeroen3
author_rank: Super Contributor
timestamp: December 22, 2014, 06:42:58 am
content: Are you doing anything equivalent?Code:RTCD1.id_rtc = RTC;/* Asynchronous part of preloader. Set it to maximum value. */uint32_t prediv_a = 0x7F;/* Disable write protection. */RTCD1.id_rtc->WPR = 0xCA;RTCD1.id_rtc->WPR = 0x53;/* If calendar not init yet. */if (!(RTC->ISR & RTC_ISR_INITS)){RTCD1.id_rtc->ISR |= RTC_ISR_INIT;while ((RTCD1.id_rtc->ISR & RTC_ISR_INITF) == 0);/* Prescaler register must be written in two SEPARATE writes. */prediv_a = (prediv_a << 16) |(((STM32_RTCCLK / (prediv_a + 1)) - 1) & 0x7FFF);RTCD1.id_rtc->PRER = prediv_a;RTCD1.id_rtc->PRER = prediv_a;RTCD1.id_rtc->ISR &= ~RTC_ISR_INIT;}Source: ChibiOS 2.6 HAL STM32F4Don't forgethal_lld_backup_domain_initin this file:http://svn.code.sf.net/p/chibios/svn/tags/ver_2.6.6/os/hal/platforms/STM32F4xx/hal_lld.c

author: russian2
author_rank: Contributor
timestamp: January 05, 2015, 04:25:32 am
content: Quote from: Ribster on December 22, 2014, 01:40:17 am

author: russian2
author_rank: Contributor
timestamp: January 20, 2015, 10:54:52 am
content: We've just designed a 176 minimalistic board with stm32f4discovery footprint, would anyone be available to check the design before I order the 1st batch?https://svn.code.sf.net/p/rusefi/code/trunk/hardware/brain_board_176-pin/176-pin_board_Schematic.pdfhttps://svn.code.sf.net/p/rusefi/code/trunk/hardware/brain_board_176-pin/176-pin_board_PCB.pdf

author: Jigsaw
author_rank: Newbie
timestamp: January 23, 2015, 05:26:17 am
content: So you just use the circuit posted in #3?That's pretty simple, I am gonna connect my chips with this circuits to try if they are OK after desoldered down from board.

author: russian2
author_rank: Contributor
timestamp: June 08, 2015, 12:19:19 pm
content: Finally got the 176 pin minimal board soldered but no life. Looking for ideas how to troubleshoot it, maybe something is missing on the schematics?https://svn.code.sf.net/p/rusefi/code/trunk/hardware/brain_board_176-pin/176-pin_board_Schematic.pdfI am using 3.3v power from stm32f4discovery and trying to connect via SWD. SilenceNo idea what the next step should be.

author: Jeroen3
author_rank: Super Contributor
timestamp: June 09, 2015, 05:35:41 am
content: Lets follow the boot procedure:- Vdd > 1.8?- Reset == Vdd?- Boot0 low? (which makes boot1don't care)- Proper caps on Vcap?- PDR_ON == Vdd?- Vbat > 1.65?Which is all I can think of from the top of my head.

author: neslekkim
author_rank: Super Contributor
timestamp: June 09, 2015, 05:40:14 am
content: Looks like one foot in two of the corners of the chip is not soldered?

author: Jeroen3
author_rank: Super Contributor
timestamp: June 09, 2015, 08:00:41 pm
content: Did you get the orientation of the chip right?I needed to grab the datasheet to find which of the 3 circles on the top is the pin 1 mark.

author: Ribster
author_rank: Frequent Contributor
timestamp: June 11, 2015, 12:05:53 am
content: Why is your reset switch going high when you press it ?It has an internal pull-up. Externally you add a cap, and to activate reset, you pull it low..EDIT: my bad, i've got the symbols mixed up. Never mind

author: russian2
author_rank: Contributor
timestamp: January 25, 2017, 09:27:04 pm
content: I should have updated this a year ago - the 176 version of the board was fixed once BYPASS_REG line was connected to GND - so with this exception the schematics was functional. See alsohttp://rusefi.com/forum/viewtopic.php?f=4&t=749We have since made little changes to the 100 pin version of the board - just an option for vertical mini USB connector and 5x2 SWD pinout matching these cheap ST-Link devices from eBay

author: ebclr
author_rank: Super Contributor
timestamp: January 29, 2017, 01:44:44 pm
content: https://img.alicdn.com/imgextra/i3/2940826774/TB2JSngXIIa61Bjy0FiXXc1XpXa_!!2940826774.jpghttps://img.alicdn.com/imgextra/i2/2940826774/TB2EyzgXTka61Bjy0FgXXbPpVXa_!!2940826774.jpghttps://world.taobao.com/item/539636211791.htm?spm=a312a.7700714.0.0.ThuIpu#detail