How to make friends with STM32
- Tutorial
No, no, no, it's not like that !
Let's be friends with STM32 correctly!
The most important mistake made by the author is the wrong toolkit. Begin to make friends with STM32 controllers, of course, with STM32Fx-Discovery boards. They already have a debugger programmer, 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 at $ 10. This is a penny for an instant and trouble-free start. Those. you don’t need to buy anything else from iron (I think there’s a mini-USB cable at home) to blink an LED, study spatial orientation systems, work with sound and graphics, and make a USB device.
An additional bonus - with a programmer from discovery, you can program external MKs, a connector for this is on the board.
But, let's say, your soul does not lie to discovery. Okay, I get it. We look then on what ST-Link V1 / V2 debuggers are based. And they are built on the STM32F103C8T6 microcontroller (@ eta4ever, yes, yes, he is the one). Accordingly, if you have a board on this MK, then it can be turned into a ST-Link V2 programmer. To upload firmware, you can use either the instruction from STM ( AN2557 STM32F10x in-application programming using the USART ) or the same discoverer, if at hand and with the STM32 ST-LINK utility . Or buy a debugger. It costs $ 25, but it’s a good thing if you are going to do it seriously.
By the way, about the board. The Chinese sell a lot of ready-made boards, like these . Such a scarf for $ 6 - not bad at all. Only such a scarf for $ 4 is better. So, we order such scarves, after receiving we turn one into a programmer, and have fun with the rest. Well, isn't it a fairy tale?
So how to make a programmer? A couple of resistors, a little wire and fifteen minutes to read this topic . What to connect with:
Firmware here with this firmware .
We’ll check everything and try. If the programmer is recognized by the system, then we connect to another board and try to flash it with some firmware (at least the same st-link), but with the help of the programmer. Everything should work.
A few words about the IDE. CooCox is not bad, convenient and all that, but they have very tight resources and do not manage to support new microcontrollers, and besides, they have priority, it seems, LPC. I ran into MK support on the STM32F0-Discovery board. I waited for the promised support for several months, but spat and went to the IAR. The Iarovsk environment is called EWARM (Embedded Workbench for ARM), the free version is enough for the eyes (code restriction is 8 kb, I have never run into it), download from here. KuKox also sins in 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 didn’t live in a hostel, where the light was cut off once an hour and does not have the habit of pressing Ctrl + S every 30 seconds, can get very hard. IAR is also not without sins, first of all, the ugly markup of the code and the lack of allocation of active / inactive code depending on the preprocessor directives infuriates, but you can live with it. It is important that just taking and building a project for STM32 just won’t work (sorry, I won’t insert a picture with Boromir). If you want, I’ll write a detailed step-by-step instruction (with pictures!) On how to create your own project from scratch.
PS But still, savage! Because on something else to take and like this from scratch to do FIG will work out:
Let's be friends with STM32 correctly!
The most important mistake made by the author is the wrong toolkit. Begin to make friends with STM32 controllers, of course, with STM32Fx-Discovery boards. They already have a debugger programmer, 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 at $ 10. This is a penny for an instant and trouble-free start. Those. you don’t need to buy anything else from iron (I think there’s a mini-USB cable at home) to blink an LED, study spatial orientation systems, work with sound and graphics, and make a USB device.
An additional bonus - with a programmer from discovery, you can program external MKs, a connector for this is on the board.
But, let's say, your soul does not lie to discovery. Okay, I get it. We look then on what ST-Link V1 / V2 debuggers are based. And they are built on the STM32F103C8T6 microcontroller (@ eta4ever, yes, yes, he is the one). Accordingly, if you have a board on this MK, then it can be turned into a ST-Link V2 programmer. To upload firmware, you can use either the instruction from STM ( AN2557 STM32F10x in-application programming using the USART ) or the same discoverer, if at hand and with the STM32 ST-LINK utility . Or buy a debugger. It costs $ 25, but it’s a good thing if you are going to do it seriously.
By the way, about the board. The Chinese sell a lot of ready-made boards, like these . Such a scarf for $ 6 - not bad at all. Only such a scarf for $ 4 is better. So, we order such scarves, after receiving we turn one into a programmer, and have fun with the rest. Well, isn't it a fairy tale?
So how to make a programmer? A couple of resistors, a little wire and fifteen minutes to read this topic . What to connect with:
- connect PA5 and PB13 this is the SWCLK line
- between the PB14 and PB12 a 220 Ohm resistor
- connect the PB14 SWDIO
- PA0 line to a divider of two 4.7 kOhms between GND and + 3.3V
Firmware here with this firmware .
We’ll check everything and try. If the programmer is recognized by the system, then we connect to another board and try to flash it with some firmware (at least the same st-link), but with the help of the programmer. Everything should work.
A few words about the IDE. CooCox is not bad, convenient and all that, but they have very tight resources and do not manage to support new microcontrollers, and besides, they have priority, it seems, LPC. I ran into MK support on the STM32F0-Discovery board. I waited for the promised support for several months, but spat and went to the IAR. The Iarovsk environment is called EWARM (Embedded Workbench for ARM), the free version is enough for the eyes (code restriction is 8 kb, I have never run into it), download from here. KuKox also sins in 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 didn’t live in a hostel, where the light was cut off once an hour and does not have the habit of pressing Ctrl + S every 30 seconds, can get very hard. IAR is also not without sins, first of all, the ugly markup of the code and the lack of allocation of active / inactive code depending on the preprocessor directives infuriates, but you can live with it. It is important that just taking and building a project for STM32 just won’t work (sorry, I won’t insert a picture with Boromir). If you want, I’ll write a detailed step-by-step instruction (with pictures!) On how to create your own project from scratch.
PS But still, savage! Because on something else to take and like this from scratch to do FIG will work out: