cancel
Showing results for 
Search instead for 
Did you mean: 

Standalone MCU Application - Unable to Flash F103

gatmt
Associate II

Hey, I am currently trying to get my own hardware to run on STM32 Microcontrollers. In this case, I am using a F103RET6, LQFP64 package. It is being used with very improvised hardware, as a proof of concept only. The layout looks like so, made in Kicad. Please be kind, it's my first rodeo. I am aware of the lacking of decoupling, filtering etc - as said, it's a prototype, I wanted to keep it as simple as possible.

gatmt_0-1693909074563.png

I am giving the circuit 9V on the left two solder pads, that are then fed into a 3.3V regulator (500mA max). It works fine up to here.

Now there are two goals: I want to have the LED (above the 220Ohms Resistor) blink so I know flashing software (a two line program that toggles PA9) worked, and ultimately test the second circuit, which is a MOSFET driving a load. At this moment, there i no such said load soldered in yet. The planned-for oscillator is currently not in use, I want to try it first with the internal resonator as to not overcomplicate things. For a better view of pinouts and the configurations:

gatmt_1-1693909456365.png

gatmt_2-1693909488186.png

gatmt_3-1693909557441.png

gatmt_4-1693909605533.png

 

 

 

 

 

gatmt_5-1693909666922.png

 

But I had two phenomena that I don't really know how to handle:

1) Between the lower right VDD and VSS pins, I had a little smoke develop when I first plugged the battery in - removing the chip later revealed a brown (probably burnt) area between both pins on the (self assembled) PCB. The reason I removed the first chip was, because after powering the board again today, (I kid you not) a little smoke turned into a very tiny "flame". I unplugged it, removed the chip, checked - discovered said burnt area, cleaned it to remove possible shorts (checking with a multimeter revealed NO short, 32kOhm when new chip soldered on and unpowered. I personally think it was some dirt trapped in leftover flux creating the connection, although, I mean, it's still only 3.3V...) and switched chips against a new one - because the whole right bank of pins had (when powered) 0.001V, while the other banks were all between 1.5 and 0.1 volts. So I assumed something burnt through with the old one, but I have no real explanation as to why. I double, if not triple checked my pinouts, power lines and soldering, and now things seem fine with the new chip after a short period of testing. I think it could have been a connection between the two pads, not directly connected to the chip itself.

gatmt_6-1693911004724.png

I figured I could leave boot tied to GND since I am using NRST to flash it, not yet the reset button.

-> Does anyone have an idea what I could have done wrong? Is it my wiring, my layout or something else?

 

2) Flashing. So I assumed it should work now, at least seeing things from an electronic standpoint.

I am using the ST-Link, cut away from a Nucleo-F446RET6 board, powered via USB from the PC. Using jumper cables, I can successfully write new programs onto the F4 belonging to the Nucleo, which is powered externally with 3.3V (since VIN somehow doesnt work with 9V, but thats another story). The four main traces I used are GND, SWDIO, SWDCLK and NRST. And as said, that works with the leftover Nucleo.

So I plugged the jumper wires into the according headers on my own board, powered that first and connected the ST-Link to my laptop via USB afterwards. First problem: It opened the media explorer, containing a file called "FAIL", stating: The interface firmware FAILED to reset/halt the target MCU

Aware of this, I tried flashing my "blink"-program anyways. As expected, it didn't work. It looks as if the ST-LINK doesnt even recognize ANY target parameter. I already updated the ST-Link to its latest available software version.

gatmt_7-1693911997386.png

Console said:

gatmt_8-1693912022900.png

And just to be complete:

while (1)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_9);
HAL_Delay(200);

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}

Debug Settings:

gatmt_9-1693912645328.png

 

I also tried all possible "Hardware reset/Software system reset/connect under reset" configurations, yet i didn't make progress. To sum it up, I dont know nearly enough to find out what's the problem here. Also, soldering this chip was as done as careful as possible, with 280°C for no longer than 10 seconds.

-> What could be the reason for this behavior? Why can I flash the Nucleo-F4, but not this one? Is it a configuration error, a hardware/layout mistake or something completely different?

Any help is greatly appreciated!!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

If I was an MCU and I saw this PCB, I would definitely be on strike! ;)

Honestly, just because it's a prototype, you don't do bad designs.
The PCB layout is absolutely terrible (e.g., GND is not some magic 0V), so is the schematics. 
As a beginner, don't be shy to copy stuff, like looking at Nucleo schematics and layout.
Wasn't there anybody to have a look at this before ordering the PCB?

You need to learn some basics before doing your first electronic designs, so as the poster before me said, buy a / or stay with the Nucleo board if you want to get things done.

PS: don't put burning gear on your jeans! ;)

View solution in original post

11 REPLIES 11
ONadr.1
Senior III

Sorry, but this MCU will not work without decoupling capacitors. These are absolutely necessary. I would recommend a NUCLEO board for initial experiments. You can also learn how to properly design a PCB.

LCE
Principal

If I was an MCU and I saw this PCB, I would definitely be on strike! ;)

Honestly, just because it's a prototype, you don't do bad designs.
The PCB layout is absolutely terrible (e.g., GND is not some magic 0V), so is the schematics. 
As a beginner, don't be shy to copy stuff, like looking at Nucleo schematics and layout.
Wasn't there anybody to have a look at this before ordering the PCB?

You need to learn some basics before doing your first electronic designs, so as the poster before me said, buy a / or stay with the Nucleo board if you want to get things done.

PS: don't put burning gear on your jeans! ;)

Thanks for your feedback. I tried redesigning it, incorporating the decoupling-scheme from the datasheet.

gatmt_0-1693996905705.png

gatmt_1-1693996999992.png

gatmt_2-1693997021138.png

It now features 100nF caps directly between Vdd/Vss 1-4, with a 4.7uF between Vdd3/Vss3.

The SWD-lines are pulled down by 10k Ohms each. NRST is pulled up (10k) aswell and decoupled by 1uF.

BOOT0 is pulled down via 100k, with a 5.1k resistor between 3.3V and the button.

The Oscillator is linked to IN and OUT, loaded, again, with two 18pF caps.

I tried to stick with other F103 layouts, especially this one (although for the 48-pin version):

https://easyeda.com/editor#id=ac71f23797414ce4bfaa2629a0781f5c

I took decoupling, osci, and the power systematic from the datasheet.

If I may ask, what do you think of this new layout? is it better, and are there things I could improve before trying this layout? Big thank you in advance!

@LCEThose are private drafts, nothing too serious. I wanted to accomplish flashing firmware to MCU's, which I could successfully do with the Nucleo, and what I needed to achieve with my own hardware. To act as a "proof of concept" I designed this board. If I may ask, how can I understand "GND is not 0V" - I mean, it makes sense electrically, but what are the consequences for a PCB? What Would I need to adjust?  Would you please be so kind as to tell me what you think of this updated design? Thank you very much!

LCE
Principal

A lot of currents are usually found on the GND "lines" - actually almost all currents "return" to the source (supply or driver) via "GND".

That means: make it BIG, which on a PCB means: make it a plane. The smaller the GND return paths are, the higher are its resistance and inductance, which lowers signal quality and might cause (also internal) EMI problems.
For most applications, a PCB should have at least 1 PCB layer reserved for a GND plane, and that without any breaks. So do not route any signal on that layer (unless you know 100% what you're doing).

I learned that stuff before much of it was on the internet, so maybe google might help with "pcb layout basics".

LCE
Principal

@gatmt I like the way you handle our harsh criticism! :) :thumbs_up:

SWD lines have the necessary internal pull-down and pull-up (!) resistors enabled at reset. NRST has an internal pull-up and it's capacitor's recommended value is 100 nF, not 1 uF. Crystals should NOT have a resistors in parallel. For BOOT0 it would be better to use a 10k pull-down and there is no need for that 5,1k series resistor.

I tried to stick with other F103 layouts, especially this one (although for the 48-pin version):

Instead read the AN2586 and look at ST's and other decent boards.


For most applications, a PCB should have at least 1 PCB layer reserved for a GND plane, and that without any breaks. So do not route any signal on that layer (unless you know 100% what you're doing).


We all know that for most non-trivial applications on two layer boards it is almost impossible or doing it can create more problems than it solves. Also the impedance of the routes will be 120-150 ohm, not the typical 50 ohm. But, if done properly, even a two layer board can do pretty much. For example, I have an Ethernet with RMII running on such a board without issues. But, of course, I totally agree that one must understand what one is doing! :)

@Lina_DABASINSKAITE , those boards truly are designed by incompetent idiots, who are located in China. Therefore censoring my sentence "Stop copying schematics made by Chinese idiots!" you are limiting the sharing of this critical information. By removing that sentence, you are barring the author and others from knowing the truth about the issue - that those designs are broken junk! And on top of this you are defending those broken junk boards, 95% of which come with fake clones of STM32, which the ST is trying to fight against. Congratulations on reaching the blindness levels of the best censors!

gatmt
Associate II

Thanks for explaining. Now the thing is, the purpose of the board, after flashing was successful, is just to blink an LED via a MOSFET. With a frequency of nothing more than 20kHz (which is really going to be the upper limit), and a peak current of theoretically 200 (but probably 20) mA. I already routed the LEDs ground path via the pin sockets, avoiding any connection with the MCUs ground traces. Question: Is a ground plane still necessary given these conditions? The power supply trace is also extracted from the rest as early as possible, see picture below. Given that this board should be kept as cheap as possible, I wanted to stick to a 2-layer-board IF possible. Thank you!

gatmt_0-1694073405074.png