Let's start with a few steps in the programming process.
First, choose a language, C or assembly language, embedded programming is currently popular or C, this requires basic and time
The second reading understands the functions of the MCU register registers, especially some IO port settings, each module clock settings such as timers, I2C, synchronous asynchronous serial port, PWM and so on, if the previous words 51 is not so set. Now the MCU basically separates each module clock. This can be seen from the official data sheet.
The purpose of the program is to set a series of registers and execute it according to the flow of your design program. During the process, some algorithms and mathematical formulas that you designed may be added. Calculate or execute.
Third, you have a piece of your experiment board just like the F429 STM32 push. You also need to download the program's programmer. It is to download the compiled code of the compiler to your target experiment board, but most of the experimental classes pushed by ST are program downloaders with their own USB serial ports. For example, STM32F429 comes with
Fourth, you still need to understand the compiler, some definitions of the compiler's data types, and some compilers may come with built-in functions, this does not have to understand. Otherwise it cannot be programmed.
This article focuses on the basics of the STM32 data types. And the meaning of some keywords.
â–² defined in the KELI MDK data type as follows
Char takes 1 byte
Short int occupies 2 bytes
Int occupies 4 bytes
Long takes 4 bytes
Long int occupies 4 bytes
Float takes 4 bytes
Double uses 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
Typedef signed short int16; // signed 16-bit short integer
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: Type data in the C language: Integer: int short long Real type: float, double.
Where Unsigned is unsigned and signed.
â–² STM32 data type macro definition
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 bytes
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 followed by comments, and others are analogized.
â–² About two keywords to explain volatile& const
(1) volatile: this keyword, many people only know to use, do not know its meaning, there is an explanation is not easy compiler optimization
The. Explained in the STM32 data plus volatile variables. These explanations are ambiguous.
For this reason, the author specifically checked the meaning of this modified keyword.
Popular explanations: Changes will be made at any time and can be modified by multiple function calls.
Abbreviated variable or volatile variable.
It's really easy to change this variable.
Advanced explanation: The significance of adding this volatile is that each time the value of this variable is taken, the request is not to take the temporary cache variable (for example, temporarily stored in a register) taken at some time last time, but directly to Take it from memory.
Personal experience: Tell the compiler that volatile defined variables must be RAM variables. Cannot be register variables.
In particular, the use of global variables must add volatile.
(2) const: In the definition of variables, if you add the keyword const, the value of the variable can not be changed during the operation of the program, of course, can no longer be assigned. This variable is called a constant variable or a read-only variable (which is more appropriate).
â–² CMSIS data types used in STM32F10x_StdPeriph_Driver 3.0 and later
Versions of 3.0 and later have different definitions of variables, but the above data types are still compatible for compatibility with older versions. 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
STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x
Find the specific definition in \stm32f10x.h.
â–² Data Types and IO Type Qualifiers Cortex-Mx HAL uses standard types defined by standard ANSI C header files. In particular, use the type qualifier IO to access peripheral variables.
Table 3 data type qualifier IO.
â–² ST removed the file "stm32f10x_type.h" from the library package. The new library uses CMSIS and the defined data types.
Table 5 shows the one-to-one correspondence between the STM32F10xxx and the data types. Table 5 Comparison of STM32F10xxx firmware library V2.0.3 and CMSIS data types
â–²Note that the original data type of the STM32F10xxx firmware library is still defined in the "stm32f10x.h" file that is compatible with the old version.
The STM32F10xxx firmware library specific type is also defined in the file "stm32f10x.h".
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;
Electric Portable Juice Blender
Electric Portable Juice Blender,Portable Juicer Blenders,Usb Rechargeable Juicer Blender,Rechargeable Juicer Blender
Shandong Sangle Group Co.,Ltd. , https://www.sangle-group.com