📜 ⬆️ ⬇️

How to be friends with STM32

No, no, no, it's not like that !

Let's be friends with STM32 right!

The main mistake made by the author is the wrong toolkit. Starting to be friends with STM32 controllers should, of course, with the STM32Fx-Discovery boards. They already have a programmer-debugger, all the necessary body kit, legs for connecting peripherals and buns in the form of LEDs, screens, sensors and DACs, depending on the board. The price of discovery starts from 10 dollars. This is a penny for an instant and trouble-free start. Those. you don’t need to buy anything more from hardware (mini-USB cable, I suppose you will find it at home) to flash the LED, study spatial orientation systems, work with sound and graphics output and make a USB device.
')
An additional bonus is that the external MK can be programmed using the programmer from the discovery;

But let's say your soul does not have a discovery. All right, I understand. We look then, on what ST-Link V1 / V2 debuggers are built. And they are built on the microcontroller STM32F103C8T6 (@ eta4ever, yes, yes, he is). Accordingly, if you have a board on this MK, then it can be turned into a ST-Link V2 programmer. To fill the firmware, you can use either the instruction from STM ( AN2557 STM32F10x in-application programming using the USART ) or the same discovery, if available, and the utility STM32 ST-LINK utility . Or buy a debugger. It costs $ 25, but the thing is useful if you are going to at least seriously deal with it.

By the way, about the board. The Chinese sell a lot of ready-made boards, like these . Such a shawl for $ 6 - not bad at all. Better just such a scarf for $ 4. So, we order such scarves, after receiving we turn one into a programmer, and have fun with the others. Well, not a fairy tale?

So how do you make a programmer? A pair of resistors, a little wire and fifteen minutes to read this topic here . What to connect with:
- connect PA5 and PB13 is a SWCLK line
- between PB14 and PB12 a 220 Ohm resistor
- SW14 line SWDIO
- Connect PA0 to a divider of two 4.7 kOhm cuts between GND and + 3.3V

We are flashing this firmware .

Check everything and try. If the programmer is recognized by the system, then we connect it to another board and try to flash it with some firmware (at least with the same St-Link), but using the programmer. Everything should work.

A few words about IDE. CooCox is not bad, convenient and all that, but they are very tight with resources and they do not have time to support new microcontrollers, and besides, their priority seems to be LPC. I ran into this with the support of the MK on the STM32F0-Discovery board. I waited for the promised support for several months, but I spat and went to IAR. Iarov's environment is called EWARM (Embedded Workbench for ARM), the free version is enough for the eyes (the code limit is 8 kb, I have never stuck with it), it is downloaded from here . Another KuCox sin is that they break something periodically in new releases and the stability of the environment is low - it can simply close all windows without saving changes. Whoever did not live in the hostel, where the light was cut out once an hour and does not have the habit of pressing Ctrl + S every 30 seconds, can get very badly. IAR is also not without sins, in the first place, the ugly markup of the code infuriates and the lack of selection of active / inactive code depending on the preprocessor directives, but you can live with it. It is important that just to take and build a project under STM32 will not work (sorry, I will not insert a picture with Boromir). If you want, I will write a detailed step-by-step instruction (with pictures!) About how to create your own project from scratch.

PS But still, savages! Because on something else to take and make a fig from scratch:

Source: https://habr.com/ru/post/247255/


All Articles