Author Topic: STM32 first project  (Read 20768 times)

0 Members and 1 Guest are viewing this topic.

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
STM32 first project
« on: October 24, 2019, 12:07:56 pm »
In a few days I'm planning to start building a project with STM32F030F4P6. (it 's just an STM32F030F4P6, not a development board)
It 's a starting LED blink project as it 's my first time I 'll try anything with an STM32 MCU.
I want to use the internal oscillator, not any external crystal.
I have installed STM32CubeMX and Atollic TrueSTUDIO.
As a programmer I 'll be using an ST-LINK V2.

I 'm trying to make a step by step tutorial for my self.  :P

So my first concern is the hardware: I 'm going to make a breakout board and connect it this way with the ST-Link:
ST-LINK.....STM32F030F4P6
RST.........NRST
SWDIO.....SWDIO
SWCLK.....SWCLK
3.3V........VDD
GND........VSS



(the STM32F030F4P6 will be getting powered from the ST-LINK)

Is this the correct way to connect them?
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: STM32 first project
« Reply #1 on: October 24, 2019, 12:17:08 pm »
Connect VDDA to VDD also, and don't forget the decoupling caps. I'd recommend a combination of a few 100n ceramic ones and an additional tantalum or electrolytic cap (10uF ... 47uF) in parallel, this helps with ringing on the supply line, especially if you get the supply from that ST-Link clone (or a real one too). Wouldn't matter much if you're just blinking an LED, but you'll probably notice the difference when you start using the ADC.

Read the datasheet to determine if you can leave BOOT0 open or need to add a pull-up or pull-down. The MCU starts an internal bootloader instead of your program if you do that wrong (can't tell this without reading the datasheet, so this is your part). Otherwise looks good.

Edit: The original ST-Link won't supply your board, the 3V3 pin is just a sense input. Don't know if the clone does.
« Last Edit: October 24, 2019, 12:30:59 pm by capt bullshot »
Safety devices hinder evolution
 
The following users thanked this post: panoss

Offline zzattack

  • Regular Contributor
  • *
  • Posts: 140
  • Country: nl
Re: STM32 first project
« Reply #2 on: October 24, 2019, 01:04:56 pm »
Always a good idea to also think about your BOOT0 pin and reset circuitry (pullup on nRST).
Personally I also prefer to start out with the 'biggest' version of your pin-compatible microcontroller. During development I hate having to use compiler optimized builds just to fit within flash, with most debugging capability severely hampered.
 
The following users thanked this post: panoss

Offline MT

  • Super Contributor
  • ***
  • Posts: 1849
  • Country: aq
Re: STM32 first project
« Reply #3 on: October 24, 2019, 02:23:20 pm »
NRST pin should have a 100n cap to DG in either case to prevent spurious resets. NRST pins have inbuilt pullups.
« Last Edit: October 24, 2019, 02:26:18 pm by MT »
 
The following users thanked this post: panoss

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: se
Re: STM32 first project
« Reply #4 on: October 24, 2019, 03:24:46 pm »
You have already got a number of good suggestions for the HW.
I would only add to use a ferrite bead from VDD to VDDA and a separate decoupling cap, of you intend to use the ADC.

This application note can also be of some help (see page 23 for a reference design).

I have installed STM32CubeMX and Atollic TrueSTUDIO.
As ATollic True Studio is no longer developed, you could install STM32CubeIDE, i.e. the integrated sum of Atollic TS and CubeMX.

Going the vendor IDE way is a path of minimal resistence, but, as my doctor says I'm allergic to Eclipse, I'll also suggest another alternative, possibly as a later step.
You can generate a Makefile from CubeMX, then use whatever IDE/Advanced editor (Sublime/Atom/VS Code) you fancy - expect doing some homework to have a functioning compile/flash/debug, though.
A number of other options exist, of course.
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: panoss

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
Re: STM32 first project
« Reply #5 on: October 24, 2019, 04:54:40 pm »
What do you think of this?



SWD_CON is a connector where the ST-Link will be connected.
ST-Link 's 3.3V will not be connected.

The MCU will be powered by a 3V3 power supply.
I have added decoupling caps to VDD and VDDA.
The RESET button just shorts the NRST to GND.
Boot0 connects through two jumbers either to 3V3 or to GND.

I have only omited the ferrite bead from VDD to VDDA because ferrite beads I 've seen are bulky, too big in size.
« Last Edit: October 24, 2019, 05:09:32 pm by panoss »
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17872
  • Country: fr
Re: STM32 first project
« Reply #6 on: October 24, 2019, 05:00:54 pm »
Looks OK to me.
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: se
Re: STM32 first project
« Reply #7 on: October 24, 2019, 05:22:52 pm »
Looks fine to me too.
FB can be found in SMD from 0402 upwards, so not really that big...but you should be OK without it.
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: panoss

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17872
  • Country: fr
Re: STM32 first project
« Reply #8 on: October 24, 2019, 05:26:45 pm »
 

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
Re: STM32 first project
« Reply #9 on: October 24, 2019, 05:55:48 pm »
If I replace the two electrolytics (C2 & C5) with SMD ceramics of the same capacity, will there be any problem?

you could install STM32CubeIDE, i.e. the integrated sum of Atollic TS and CubeMX
STM32CubeIDE is only for 64bit machines, as far as I can tell...
I 'm using a 32 bit Win 7 machine for MCU programming, so I guess I 'll have to go back to STM32CubeMX and Atollic TrueSTUDIO, right?
« Last Edit: October 24, 2019, 06:38:56 pm by panoss »
 

Offline jhpadjustable

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: us
  • Salt 'n' pepper beard
Re: STM32 first project
« Reply #10 on: October 24, 2019, 07:12:44 pm »
You shouldn't have used electrolytics in the first place. From the datasheet, section 6.1.6, "Power supply scheme":
Quote from: ST Microelectronics
Each power supply pair (V DD /V SS , V DDA /V SSA etc.) must be decoupled with filtering ceramic
capacitors as shown above. These capacitors must be placed as close as possible to, or
below, the appropriate pins on the underside of the PCB to ensure the good functionality of
the device.

Everything else looks alright to me.
"There are more things in heaven and earth, Arduino, than are dreamt of in your philosophy."
 
The following users thanked this post: panoss

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17872
  • Country: fr
Re: STM32 first project
« Reply #11 on: October 24, 2019, 07:33:41 pm »
The ceramic caps (even though they are not explicitely marked as ceramic, we can assume they are) are all there in the OP's schematic.
 

Offline jhpadjustable

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: us
  • Salt 'n' pepper beard
Re: STM32 first project
« Reply #12 on: October 24, 2019, 07:48:25 pm »
(even though they are not explicitely marked as ceramic, we can assume they are)
Not if OP's asking. :)
If I replace the two electrolytics (C2 & C5) with SMD ceramics of the same capacity, will there be any problem?
"There are more things in heaven and earth, Arduino, than are dreamt of in your philosophy."
 

Online Kleinstein

  • Super Contributor
  • ***
  • Posts: 17336
  • Country: de
Re: STM32 first project
« Reply #13 on: October 24, 2019, 08:06:12 pm »
For C2 and C5 it helps to have capacitors with some ESR. So ceramic are not as good as electrolytic ones in this case. A ceramic cap with some 1-10 Ohms in series would be a better substitute for an electrolytic cap.   
With decoupling also the layout can have quite some effect. Digital circuits are often quite robust and may work even if large mistakes in the decoupling are made - however with a poor layout or wrong caps chances are higher it may fail or produce EMI.

If one has not ferrite bead or other separation one may not need both C2 and C5, as they are in parallel.
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 17872
  • Country: fr
Re: STM32 first project
« Reply #14 on: October 24, 2019, 08:26:39 pm »
(even though they are not explicitely marked as ceramic, we can assume they are)
Not if OP's asking. :)
If I replace the two electrolytics (C2 & C5) with SMD ceramics of the same capacity, will there be any problem?

Well. Dunno if we talk about the same thing, or understand each other.

The OP has put ceramic caps (100n, 10n) for decoupling, we can assume he's going to put them close to the IC. This is just what ST suggests. The reason is they have very low ESR and behave reasonably well at high frequencies, so they are better than electrolytic caps for just that.

I admit the OP's schematic is a bit ambiguous though, as the electrolytic caps are drawn closer to the IC - he should move the ceramic bypass caps closer to the MCU to make it clearer, although it's not strictly required (some people even put their bypass caps separately in their schematics, I don't like it, but hey...)

There's no problem adding larger caps, on top of that, as electrolytic or tantalum caps, though. But yes, you'd typically place them further away. So I guess our misunderstanding comes more from the "drawing" style than from the schematic content itself, which to me was correct. Then the question would have been the layout. But maybe you were able to "read" from the OP's posts and drawing style that he was going to get the layout wrong.

For simplication, for VDDA, I would personally just replace C4 and C5 with just ONE 10µF ceramic cap (this is what I usually do). Of course as close to the MCU as possible. As for C2, it's probably useless here, but it won't hurt. Just place it closer to the power supply connector than to the MCU.

As there is only one VDD pin, I would also get rid of one of the 100nF caps. Only one is enough.
« Last Edit: October 24, 2019, 08:28:37 pm by SiliconWizard »
 

Offline MT

  • Super Contributor
  • ***
  • Posts: 1849
  • Country: aq
Re: STM32 first project
« Reply #15 on: October 24, 2019, 09:13:45 pm »
If I replace the two electrolytics (C2 & C5) with SMD ceramics of the same capacity, will there be any problem?

you could install STM32CubeIDE, i.e. the integrated sum of Atollic TS and CubeMX
STM32CubeIDE is only for 64bit machines, as far as I can tell...
I 'm using a 32 bit Win 7 machine for MCU programming, so I guess I 'll have to go back to STM32CubeMX and Atollic TrueSTUDIO, right?

Win32bit Attolic 9.3 are still available , F030 are supported from 9.0 version.
https://atollic.com/resources/download/windows/windows-archive/?submissionGuid=7b9dd1fb-0c42-4cd4-aa4b-bbf08d1eb48f
« Last Edit: October 24, 2019, 09:15:40 pm by MT »
 
The following users thanked this post: newbrain

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 9950
  • Country: ca
  • Non-expert
Re: STM32 first project
« Reply #16 on: October 24, 2019, 10:25:13 pm »
Edit: The original ST-Link won't supply your board, the 3V3 pin is just a sense input. Don't know if the clone does.

Clone stlink outputs 3.3V so its is OK to power the circuit.
5V output is also available (direct from USB).
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline jhpadjustable

  • Frequent Contributor
  • **
  • Posts: 295
  • Country: us
  • Salt 'n' pepper beard
Re: STM32 first project
« Reply #17 on: October 25, 2019, 12:23:15 am »
Well. Dunno if we talk about the same thing, or understand each other.

The OP has put ceramic caps (100n, 10n) for decoupling, we can assume he's going to put them close to the IC. This is just what ST suggests. The reason is they have very low ESR and behave reasonably well at high frequencies, so they are better than electrolytic caps for just that.

I read those five caps in panoss's schematic as a straightforward copy of the datasheet recommendation, due to their values, the 10µF being an order larger than recommended but not completely out of line. Aside, on STM32 devices with more than 3 VDD/VSS pairs, the designer is cautioned to place the larger per-rail (not per-pin-pair) cap, here 4.7µF, nearest a particular VDD/VSS pin pair, which leads me to believe the larger caps are meant for the whole device, not as a recommendation for the whole system. Excessive in the present case? Probably, but ceramic chip caps are sooo cheap these days. :D

Not to hijack, but under what sort of circumstances would you choose not to merge the two VDDA caps?

Quote
As there is only one VDD pin, I would also get rid of one of the 100nF caps. Only one is enough.
Agreed. ST's recommendation hints, but doesn't explicitly state, 100nF per VDD/VSS pin pair is only necessary on pin pairs that are actually pinned out.
"There are more things in heaven and earth, Arduino, than are dreamt of in your philosophy."
 

Offline DBecker

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: us
Re: STM32 first project
« Reply #18 on: October 25, 2019, 05:03:25 am »
You might take all of these recommendations with a grain of salt.

Most of the external parts are not absolutely required.  You want them in a commercial product that needs to work in a wide range of circumstances and pass noise emissions tests.  But for a hobby project where you are hand soldering each part you can skip all of them and things will still work.

Specifically you don't need external components on the reset pin in most circumstances.  The STM32 has sophisticated internal circuits to handle power on reset and brown-out shutdown.  I've seen old-fashioned designs that use a capacitor and resistor to generate a power-on reset.  This can actually defeat the reliable internal circuit.  Using just a capacitor is less likely to cause a problem, but it's only necessary if the reset circuit has a long wire likely to pick up lots of noise.  The STM32 isn't going to reset from noise with nothing connected to the pin.

For the power supply decoupling capacitors you can get away with using far less than the full set, especially if you are not simultaneously switching the output drivers into their maximum load.  The core runs off of a internal regulator that is typically 1.2V (lower for more modern cores).  Your main supply has to dip close to that before you'll impact operation.  Sure, you won't be delighted with the ADC performance, but you aren't going to be getting representative results with a hand-wired prototype anyway.


 

Offline techman-001

  • Frequent Contributor
  • **
  • !
  • Posts: 748
  • Country: au
  • Electronics technician for the last 50 years
    • Mecrisp Stellaris Unofficial UserDoc
Re: STM32 first project
« Reply #19 on: October 25, 2019, 05:50:11 am »
You might take all of these recommendations with a grain of salt. Most of the external parts are not absolutely required.

That's right, attached is a pic of my hand soldered, standalone, STM32F051 one external component ( a cap across the 3.3 supply) module.

I flashed it using the internal serial bootloader. It runs Forth internally using 3.3v power from a typical USB/3.3v serial dongle.

 

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
Re: STM32 first project
« Reply #20 on: October 25, 2019, 09:06:41 am »
I followed your suggestions and changed a few things:
-I put the ceramic cap (100n) for decoupling close to the IC, as closer as I could.(in the layout)
-I  replaced the electrolytics with ceramics.
-I replaced C4 and C5 with just ONE 10µF ceramic (I just removed C4), and in the layout I put it as close to the MCU as possible.
-C2 removed.
-One of the 100n caps (C3) was removed.



Any further suggestion would be welcome.
« Last Edit: October 25, 2019, 09:10:03 am by panoss »
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: STM32 first project
« Reply #21 on: October 25, 2019, 11:19:19 am »
I think you've got all that ceramic / electrolytic discussion wrong - There's nothing wrong with the ceramic caps, but if you use them alone you may run into supply voltage ringing issues. You should add some damping here, one (quite classical and simple) method would be to use an electrolytic or tantalum instead of the larger ceramic cap. Another method would be to add some resistance to the larger ceramic (put a 1R ... 2R2 resistor in series with it). As long as you don't use the ADC, you most probably won't notice the difference.

Others are right too, you don't need a capacitor tied to the NRST pin. Having a onboard LED is a good measure, it could also be useful to fan out "standard" UART pins to a 3pin header for "printf debugging" purposes.
Safety devices hinder evolution
 

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
Re: STM32 first project
« Reply #22 on: October 25, 2019, 11:55:39 am »
So, if I put a 1 Ohm resistor in series with C5 and remove C6 I 'll be ok?
« Last Edit: October 25, 2019, 11:59:36 am by panoss »
 

Offline newbrain

  • Super Contributor
  • ***
  • Posts: 1920
  • Country: se
Re: STM32 first project
« Reply #23 on: October 25, 2019, 12:30:45 pm »
Others are right too, you don't need a capacitor tied to the NRST pin.
I disagree, for two reasons:
  • There's a reset button, in this case the cap is explicitly recommended in both the reference manual and the hardware app note.
  • At least one other very experienced member of this forum has had some issues when omitting the cap (though on other STM32 series, IIRC).

Having a onboard LED is a good measure, it could also be useful to fan out "standard" UART pins to a 3pin header for "printf debugging" purposes.
A very good suggestion!

So, if I put a 1 Ohm resistor in series with C5 and remove C6 I 'll be ok?
I would not remove C6, as stated above.
The stability of the supply vs. ESR of the decoupling caps depends on many factors (specific regulator/LDO, cable length etc.) - you could experiment a bit.
Nandemo wa shiranai wa yo, shitteru koto dake.
 
The following users thanked this post: MT, jhpadjustable

Offline panossTopic starter

  • Frequent Contributor
  • **
  • Posts: 327
  • Country: gr
Re: STM32 first project
« Reply #24 on: October 25, 2019, 01:51:29 pm »
Ok, C6 stays.

it could also be useful to fan out "standard" UART pins to a 3pin header for "printf debugging" purposes.
If I understand correctly you mean a Serial port that I could use the way it 's used in Arduino?
Yes I 'd like to have the possibility to Serial.print(something).
I think it 's necessary.
How can I do this?
Should I change something in the circuit to achieve this?
« Last Edit: October 25, 2019, 01:56:39 pm by panoss »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->