STM32 Programming. Part 1-2: Documentation
Posted: 14 Oct 2023, 04:21
The best way to start getting to know any thing is to start with the manual. In some cases everything is clear, in others - "hmm, nothing works, I guess I should read the manual after all". Microcontrollers are quite complex devices, and without reading the documentation you will certainly not be able to do anything useful with them, though....
In this article we will look at how the manufacturer's official website organizes the documentation for STM32 microcontrollers, in particular the STM32F1 series.
After some AVR-oks, you may be slightly shocked by the number of different PDFs on STM32 microcontrollers. Where to look first of all? How to use it? What the hell is going on? At first glance nothing is clear. So I decided to make a small review of the world of documentation on these wonderful microcontrollers. I will emphasize on STM32F103C8T6, as I plan to write some lessons on how to use this particular stone.
The main documents for STM-ki are the following:
Datasheet contains information about the presence of certain peripherals in a particular MCU, pinout, electrical characteristics and chip labeling for STM32F103x8 and STM32F103xB, i.e. for these ones, which are circled with a red rectangle:
Not bad, one datasheet for 8 microcontrollers.
The main things in the Datasheet
First of all you should pay attention to section 7. Ordering information scheme, which specifies what each symbol in the marking means. For example, for STM32F103C8T6: LQFP-48 case, 64Kb flash, temperature range -40 to 85 °C.
Next is 2.1 Device overview. It has a table that tells you what peripherals a particular microcontroller has and how many:
The main difference between the microcontrollers from different columns is the number of legs and the amount of flash, the rest is the same. A small exception is the first column of Tx versions: these microcontrollers have fewer SPI, I2C and USART modules. Peripherals are numbered from one: that is, if in STM32F103Cx we have 2 SPIs, they are named SPI1 and SPI2, while in STM32F103Tx we have only SPI1. Since we have Datasheet for STM32F103x8 and STM32F103xB microcontrollers, this table is valid only for these models. For example, STM32F103C8 or STM32F103CB correspond to this table, but STM32F103C6 does not, there is a separate datasheet for it.
Section 2.2 Full compatibility throughout the family states that STM32F103xx devices are programmatically, functionally and pin-to-pin (for the same packages) compatible.
In the reference manual there is a division into the following "types" of microcontrollers: STM32F103x4 and STM32F103x6 are designated as low-density devices, STM32F103x8 and STM32F103xB as medium-density devices, STM32F103xC, STM32F103xD and STM32F103xE as high-density devices. Low-density devices have less Flash and RAM memory, timers and peripherals. High-density devices have more Flash and RAM memory, as well as have additional peripherals such as SDIO, FSMC, I2S and DAC, while remaining fully compatible with other members of the STM32F103xx family. That is, if at some stage of development it became clear that the selected microcontroller is not enough to realize all the possibilities, you can painlessly choose a more advanced stone without the need to rewrite all the existing software, and if the new stone will be in the same case, there is no need to re-design the printed circuit board.
Reference manual
Let's move on. Reference manual contains a detailed description of all peripherals, registers, offsets, and so on. This is the main document that is used when creating firmware for the microcontroller. Reference manual is compiled for a large group of microcontrollers, in our case for all STM32F10xxx, namely STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx. But STM32F100xx are not included in this RM, there is its own for them.
The main thing in the Reference manual
As mentioned above, the reference manual divides the microcontrollers into the following "types": low-, medium-, high-density and connectivity.
line. Glossary 2.3 explains who is who:
Next, let's turn to Tabe 1. It notes which section applies to a particular type of microcontrollers. In our case it is Medium-density STM32F103xx:
Then it's simple: there are a bunch of sections, each with a description on a specific peripheral and its registers
Programming Manual
The Programming Manual is not a document of the first necessity at the very beginning of the introduction to STMs, but it is very important when studying these microcontrollers in depth. It contains information about the processor core, instruction system and core periphery. It is not the same periphery described in the Reference manual. It includes:
Errata Sheet
Errata Sheet is a collection of all known hardware glitches and glitches of microcontrollers and tips on how to get around them. Quite a fun document Before using any peripheral, I suggest you take a look. It may help to reduce the number of lost nerve cells when debugging your miracle firmware that doesn't want to work in any way
In this article we will look at how the manufacturer's official website organizes the documentation for STM32 microcontrollers, in particular the STM32F1 series.
After some AVR-oks, you may be slightly shocked by the number of different PDFs on STM32 microcontrollers. Where to look first of all? How to use it? What the hell is going on? At first glance nothing is clear. So I decided to make a small review of the world of documentation on these wonderful microcontrollers. I will emphasize on STM32F103C8T6, as I plan to write some lessons on how to use this particular stone.
The main documents for STM-ki are the following:
- Datasheet
- Reference manual
- Programming Manual
- Errata Sheet
Datasheet contains information about the presence of certain peripherals in a particular MCU, pinout, electrical characteristics and chip labeling for STM32F103x8 and STM32F103xB, i.e. for these ones, which are circled with a red rectangle:
Not bad, one datasheet for 8 microcontrollers.
The main things in the Datasheet
First of all you should pay attention to section 7. Ordering information scheme, which specifies what each symbol in the marking means. For example, for STM32F103C8T6: LQFP-48 case, 64Kb flash, temperature range -40 to 85 °C.
Next is 2.1 Device overview. It has a table that tells you what peripherals a particular microcontroller has and how many:
The main difference between the microcontrollers from different columns is the number of legs and the amount of flash, the rest is the same. A small exception is the first column of Tx versions: these microcontrollers have fewer SPI, I2C and USART modules. Peripherals are numbered from one: that is, if in STM32F103Cx we have 2 SPIs, they are named SPI1 and SPI2, while in STM32F103Tx we have only SPI1. Since we have Datasheet for STM32F103x8 and STM32F103xB microcontrollers, this table is valid only for these models. For example, STM32F103C8 or STM32F103CB correspond to this table, but STM32F103C6 does not, there is a separate datasheet for it.
Section 2.2 Full compatibility throughout the family states that STM32F103xx devices are programmatically, functionally and pin-to-pin (for the same packages) compatible.
In the reference manual there is a division into the following "types" of microcontrollers: STM32F103x4 and STM32F103x6 are designated as low-density devices, STM32F103x8 and STM32F103xB as medium-density devices, STM32F103xC, STM32F103xD and STM32F103xE as high-density devices. Low-density devices have less Flash and RAM memory, timers and peripherals. High-density devices have more Flash and RAM memory, as well as have additional peripherals such as SDIO, FSMC, I2S and DAC, while remaining fully compatible with other members of the STM32F103xx family. That is, if at some stage of development it became clear that the selected microcontroller is not enough to realize all the possibilities, you can painlessly choose a more advanced stone without the need to rewrite all the existing software, and if the new stone will be in the same case, there is no need to re-design the printed circuit board.
Reference manual
Let's move on. Reference manual contains a detailed description of all peripherals, registers, offsets, and so on. This is the main document that is used when creating firmware for the microcontroller. Reference manual is compiled for a large group of microcontrollers, in our case for all STM32F10xxx, namely STM32F101xx, STM32F102xx, STM32F103xx and STM32F105xx/STM32F107xx. But STM32F100xx are not included in this RM, there is its own for them.
The main thing in the Reference manual
As mentioned above, the reference manual divides the microcontrollers into the following "types": low-, medium-, high-density and connectivity.
line. Glossary 2.3 explains who is who:
- Low-density devices are STM32F101xx, STM32F102xx, and STM32F103xx microcontrollers that have Flash memory sizes between 16 and 32 Kbytes.
- Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx, with Flash memory size between 64 and 128 Kbytes.
- High-density devices
- XL-density devices are STM32F101xx and STM32F103xx, flash memory size between 768 Kbytes and 1 Mbyte.
- Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.
Next, let's turn to Tabe 1. It notes which section applies to a particular type of microcontrollers. In our case it is Medium-density STM32F103xx:
Then it's simple: there are a bunch of sections, each with a description on a specific peripheral and its registers
Programming Manual
The Programming Manual is not a document of the first necessity at the very beginning of the introduction to STMs, but it is very important when studying these microcontrollers in depth. It contains information about the processor core, instruction system and core periphery. It is not the same periphery described in the Reference manual. It includes:
- System timer - system timer
- Nested vectored interrupt controller - priority interrupt controller
- System control block
- Memory protection unit
Errata Sheet
Errata Sheet is a collection of all known hardware glitches and glitches of microcontrollers and tips on how to get around them. Quite a fun document Before using any peripheral, I suggest you take a look. It may help to reduce the number of lost nerve cells when debugging your miracle firmware that doesn't want to work in any way