Author Topic: STM32F4 Minimal circuit  (Read 46510 times)

0 Members and 1 Guest are viewing this topic.

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
STM32F4 Minimal circuit
« on: July 05, 2014, 06:12:22 pm »
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.
 
The following users thanked this post: zzattack, ZeroResistance

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM32F4 Minimal circuit
« Reply #1 on: July 05, 2014, 07:03:29 pm »
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.
« Last Edit: July 05, 2014, 07:09:34 pm by andyturk »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F4 Minimal circuit
« Reply #2 on: July 05, 2014, 08:16:36 pm »
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.

Quote
What else do I need if I want to use the internal RTC? Probably something connected to the VBAT pin?

A battery?

I typically put a small serial resistor (22-47ohm) just in case I accidentally put power on the trace.
================================
https://dannyelectronics.wordpress.com/
 

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
Re: STM32F4 Minimal circuit
« Reply #3 on: July 05, 2014, 09:06:56 pm »
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:
Quote
VBAT = 1.65 to 3.6 V: power supply for RTC, external clock 32 kHz oscillator and backup registers (through power switch) when VDD is not present.
That "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.
 

Offline sfiber

  • Regular Contributor
  • *
  • Posts: 107
  • Country: tr
Re: STM32F4 Minimal circuit
« Reply #4 on: July 05, 2014, 09:18:42 pm »
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
 

Offline andyturk

  • Frequent Contributor
  • **
  • Posts: 895
  • Country: us
Re: STM32F4 Minimal circuit
« Reply #5 on: July 05, 2014, 09:40:50 pm »
That "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 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.


 

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
Re: STM32F4 Minimal circuit
« Reply #6 on: July 06, 2014, 12:00:35 pm »
That makes sense. At least I think so.

According to the datasheet:
Quote
The VBAT pin allows to power the device VBAT domain from an external battery, an external supercapacitor, or from VDD when no external battery and an external supercapacitor are present.
VBAT operation is activated when VDD is not present.

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

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F4 Minimal circuit
« Reply #7 on: July 06, 2014, 01:27:58 pm »
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.
================================
https://dannyelectronics.wordpress.com/
 

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
Re: STM32F4 Minimal circuit
« Reply #8 on: July 07, 2014, 01:17:19 pm »
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.
 

Offline Legit-Design

  • Frequent Contributor
  • **
  • Posts: 562
Re: STM32F4 Minimal circuit
« Reply #9 on: July 07, 2014, 01:33:32 pm »
http://rusefi.com/forum/viewtopic.php?f=4&t=381

http://rusefi.com/forum/viewtopic.php?f=4&t=381
Minimal 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
Brain board

The brain board can be the off the shelf STMDiscoveryF4. However the Discovery has several circuits like the analog microphone circuits which change how a particular pin is loaded. We have noticed that this pin loading cause the injector circuits to vary pulse widths. Because of this we have developed a stripped down version of the discovery board with out the extra circuits. Both boards have the same general specifications, same clock rates, same IO headers with the same pin out's, ect.
« Last Edit: July 07, 2014, 01:36:12 pm by Legit-Design »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: STM32F4 Minimal circuit
« Reply #10 on: July 07, 2014, 02:52:11 pm »
-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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Legit-Design

  • Frequent Contributor
  • **
  • Posts: 562
Re: STM32F4 Minimal circuit
« Reply #11 on: July 07, 2014, 03:04:04 pm »
Use your fingers as caps, I remember Jeri Ellsworth told in one interview how to worked a treat.  :-+
 

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
Re: STM32F4 Minimal circuit
« Reply #12 on: July 07, 2014, 08:59:18 pm »
@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.

Quote
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.
Do 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.
 

Offline Legit-Design

  • Frequent Contributor
  • **
  • Posts: 562
Re: STM32F4 Minimal circuit
« Reply #13 on: July 07, 2014, 09:21:36 pm »
@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.
Be sure to read the whole thread for problems/solutions, and if you fix something or make it better please share.
 

Offline gxti

  • Frequent Contributor
  • **
  • Posts: 507
  • Country: us
Re: STM32F4 Minimal circuit
« Reply #14 on: July 07, 2014, 10:36:00 pm »
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.
 

Online Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F4 Minimal circuit
« Reply #15 on: July 08, 2014, 03:29:32 pm »
Quote
LSE will run from VBAT
This 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.pdf
Or 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.
 

Offline sfiber

  • Regular Contributor
  • *
  • Posts: 107
  • Country: tr
Re: STM32F4 Minimal circuit
« Reply #16 on: July 19, 2014, 08:46:06 am »
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.
 

Offline Ribster

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: be
  • Electronics prototyper. Design. Prototype. Consult
    • Ash Labs
Re: STM32F4 Minimal circuit
« Reply #17 on: July 23, 2014, 11:12:38 am »
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..
www.ashlabs.be
Design and manufacturing of embedded hard- and software
 

Offline roliTopic starter

  • Regular Contributor
  • *
  • Posts: 69
  • Country: si
Re: STM32F4 Minimal circuit
« Reply #18 on: July 24, 2014, 05:11:19 pm »
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!
 

Offline Ribster

  • Frequent Contributor
  • **
  • Posts: 250
  • Country: be
  • Electronics prototyper. Design. Prototype. Consult
    • Ash Labs
Re: STM32F4 Minimal circuit
« Reply #19 on: December 22, 2014, 01:40:17 am »
Did you get it working ?
Can you share some pics / code ?

Thanks
www.ashlabs.be
Design and manufacturing of embedded hard- and software
 

Online Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: STM32F4 Minimal circuit
« Reply #20 on: December 22, 2014, 06:42:58 am »
Are you doing anything equivalent?
Code: [Select]
  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 STM32F4

Don't forget hal_lld_backup_domain_init in this file: http://svn.code.sf.net/p/chibios/svn/tags/ver_2.6.6/os/hal/platforms/STM32F4xx/hal_lld.c
 

Offline russian2

  • Contributor
  • Posts: 18
Re: STM32F4 Minimal circuit
« Reply #21 on: January 05, 2015, 04:25:32 am »
Did you get it working ?
Can you share some pics / code ?

 

Offline russian2

  • Contributor
  • Posts: 18
Re: STM32F4 Minimal circuit
« Reply #22 on: January 20, 2015, 10:54:52 am »


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.pdf
https://svn.code.sf.net/p/rusefi/code/trunk/hardware/brain_board_176-pin/176-pin_board_PCB.pdf
 

Offline Jigsaw

  • Newbie
  • Posts: 1
Re: STM32F4 Minimal circuit
« Reply #23 on: January 23, 2015, 05:26:17 am »
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.
 

Offline russian2

  • Contributor
  • Posts: 18
Re: STM32F4 Minimal circuit
« Reply #24 on: June 08, 2015, 12:19:19 pm »
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.pdf

I am using 3.3v power from stm32f4discovery and trying to connect via SWD. Silence :( No idea what  the next step should be.




 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf