STM32 data type basic introduction

Let me talk about a few steps in the programming process first

First, choose a language, C language or assembly language, embedded programming is generally popular or C, this requires foundation and time

Second read to understand the function of each register of the MCU register, especially some IO port settings, each module clock settings such as timer, I2C, synchronous asynchronous serial port, PWM, etc., the previous 51 words did not have such settings. But now the MCU basically separates the clock of each module. This can be seen in the official data sheet.

In fact, the purpose of the program is to set up a series of registers. According to the flow of your design program to execute it, some algorithms and mathematical formulas that you have designed may be added during the process. Make calculations, or execute.

Third, you have an experiment board like the F429 pushed by STM32 this time, you also need to download the programmer. It is to download the code compiled by the compiler to your target experiment board, but most of the experimental classes pushed by ST are program downloaders with USB serial ports. For example, STM32F429 comes with it

Fourth, you also need to understand the compiler, some definitions of the compiler's data types, and some compilers may come with built-in functions. Otherwise, it cannot be programmed.

This article mainly introduces the basic knowledge of STM32 data types. And the meaning of some keywords.

â–² The following definitions have been entered in the KELI MDK data type

char takes 1 byte

short int takes 2 bytes

int takes 4 bytes

long takes 4 bytes

long int takes 4 bytes

float takes 4 bytes

double takes 8 bytes

That is, the following macro definition

typedef unsigned char uint8; // Unsigned 8-bit character variable

typedef signed char int8; // signed 8-bit character variable
typedef unsigned short uint16; // unsigned 16-bit short integer variable
typedef signed short int16; // signed 16-bit short integer variable
typedef unsigned int uint32; // unsigned 32-bit integer variable
typedef signed int int32; // signed 32-bit integer variable

typedef float fp32; // single-precision floating-point number (32-bit length)

typedef double fp64; // double-precision floating-point number (64-bit length)

Note: Kind data in C language: integer type: int short long real type: float, double.

Among them, Unsigned is unsigned and signed is signed.

â–² Macro definition of STM32 data type

STM32 uses a large number of firmware libraries, of which there are 24 data types in the 2.0 library as follows
typedef unsigned char u8; 0 ~ 255 one byte

typedef signed char s8; -128 ~ 127

typedef volaTIle unsigned char vu8;

typedef volaTIle signed char vs8;

typedef unsigned char const uc8;

typedef signed char const sc8;

typedef volaTIle unsigned char const vuc8;

typedef volaTIle signed char const vsc8;

typedef unsigned short u16; 0 ~ 65535 two bytes

typedef signed short s16; -32768 ~ 32767 two bytes

typedef volatile unsigned short vu16;

typedef volatile signed short vs16;

typedef unsigned short const uc16;

typedef signed short const sc16;

typedef signed short const sc16;

typedef volatile unsigned short const vuc16;

typedef volatile signed short const vsc16;

typedef unsigned long u32; 0 ~ (2 ^ 32-1) four bytes

typedef signed long s32;

typedef signed long const sc32;

typedef volatile unsigned long const vuc32;

typedef volatile signed long const vsc32;

Some data types are commented back, and others are analogized.

â–² About two keywords volatile & const

(1) volatile: This keyword, many people only know the use, do not know its meaning, there is an introduction to explain is not easy to be optimized by the compiler

Chemical. In the STM32 data, explain the addition of volatile variables. These explanations are vague.

For this reason, the author specifically checked the meaning of this modified keyword

Popular explanation: It can change at any time, and can be modified by volatile by multiple function calls.

Referred to as variable or volatile variables.

This variable is really easy to change.

Advanced explanation: The meaning of adding this volatile is that each time the value of this variable is taken, the requirement is not to take the temporary cache variable it fetched at a certain time last time (for example, temporarily stored in a certain register), but directly to Get in memory.

Personal experience: Tell the compiler that variables defined by volatile must be RAM variables. They cannot be register variables.

In particular, global variables used in interrupts must be volatile.

(2) const: When defining a variable, if you add the keyword const, the value of the variable cannot be changed during the running of the program, and of course it cannot be assigned any more. This kind of variable is called a constant variable or read-only-variable, which is more appropriate.

â–² The CMSIS data type is used in STM32F10x_StdPeriph_Driver 3.0 and later

The definitions of variables in versions after 3.0 are different from the previous versions, but for the purpose of compatibility with older versions, the above data types are still compatible. The IO type qualifiers of CMSIS are shown in Table 3, and the data types of CMSIS and STM32 firmware libraries are shown in Table 5. These data types can be found in

STM32F10x_StdPeriph_Lib_V3.4.0 \ Libraries \ CMSIS \ CM3 \ DeviceSupport \ ST \ STM32F10x

Find specific definitions in \ stm32f10x.h.

â–² Data type and IO type qualifier Cortex-Mx HAL uses the standard type defined by the standard ANSI C header file. In particular, use the type qualifier IO to access the variables of the peripheral.
Table 3 Data type qualifier IO.

STM32 data type basic introduction

â–² ST removed the file "stm32f10x_type.h" from the library package. The new library uses CMSIS and defined data types.

Table 5 shows the one-to-one correspondence between STM32F10xxx and data types. Table 5 STM32F10xxx firmware library V2.0.3 and CMSIS data type comparison

STM32 data type basic introduction

â–² Note that the original data type of the STM32F10xxx firmware library is still defined in the file "stm32f10x.h" for compatibility with the old version.

The file "stm32f10x.h" also defines the special type of STM32F10xxx firmware library.

They are: typedef enum {FALSE = 0, TRUE =! FALSE} bool;

typedef enum {RESET = 0, SET =! RESET} FlagStatus, ITStatus;

typedef enum {DISABLE = 0, ENABLE =! DISABLE} FunctionalState;

#define IS_FUNCTIONAL_STATE (STATE) (((STATE) == DISABLE) || ((STATE) == ENABLE))

typedef enum {ERROR = 0, SUCCESS =! ERROR} ErrorStatus;

Student Laptop

Do you know which is the most competitive student laptop for elementary students or daily entertainment? It`s this 14.1 inch celeron n4020 64gb laptops on sale for students, since not only lightweight, but also entry celeron cpu, storage, longer lasting battery, etc. More than 80% clients choose this student chromebooks for students tender cause it`s of all features of laptop for online classes. Of course, this model is also suitable for operating student laptop deals.

As a professional oem&ODM manufacture, never let you down. No matter you look for 14inch 64gb student pc, 15.6 inch N5095 Teacher Laptop, 15.6 inch 10th or 11th University Laptop, 16.1 inch 4gb graphics recommended laptop for programming, Android Tablet, Mini PC or All In One PC , always have the right one here for you.

Therefore, just feel free to contact us and share your basic requirement, like size, cpu, ram, rm, quantity, special requirements, so that send back right details for you.

Student Laptop,Student Laptop Deals,Laptops On Sale For Students,Student Pc,Laptop For Online Classes

Henan Shuyi Electronics Co., Ltd. , https://www.shuyitablet.com

This entry was posted in on