Table of contents
If you use only the peripheral library, you do not need to be aware of the register map, but understanding how the MCU's registers are operated in the library will improve your MCU skills.
From a different perspective, the level of register manipulation without the use of libraries is the most powerful because it allows development without relying on the libraries and tools provided by each MCU manufacturer.
Let's look at how the peripheral library operates the control registers of the peripherals. It is possible to develop MCU without understanding how the peripheral library works as a black box. Moreover, understanding register manipulation is considered very difficult for beginners, especially those who are not very familiar with programming, so you can skip this section.
As an advanced MCU user, you will be able to create applications with smaller program code and faster processing speeds if you can manipulate registers directly without relying on libraries created by the manufacturer. This is not an essential skill, but if you can use it as needed, it will become more applicable and powerful.
Let's trace how the general-purpose input/output GPIOA_1 pin was set as a push-pull output by the peripheral library in the previous section.
The memory map of the peripheral is shown below. In this map, the base address in memory of GPIO port A is 0x40010800 in 32-bit notation.
Description in the program using the library
Let's see how the library functions in an actual program.
Let's check the details of the parts of the structure that are grouped together. Parameters are grouped by structure for each classification.
About initialization function xx_Init()
Let me explain how register addresses and setting parameters are processed in the initialization function GPIO_Init(GPIOx, &GPIO_InitStructure) to manipulate the registers.
The actual program is the GPIO_init() function in stm32f10x_gpio.c of the GPIO library.
The above is the process performed by the initialization function GPIO_Init(GPIOx, &GPIO_InitStructure).
In the initial setting of peripherals, you identify the address of the corresponding control register, not only GPIO, and write the parameters you want to set, either by using a peripheral library (device driver) or by writing directly to the register.
While the peripheral library is convenient and easy to use without knowing the control registers, it also has redundant parts, so direct manipulation of registers may be necessary to reduce program code size and improve processing speed.
If you are using a high-performance microcontroller with sufficient processing speed and memory size for program storage, you may want to use only the more convenient peripheral library and concentrate on application development.