当前位置:网站首页>STM32 single chip microcomputer -- volatile keyword
STM32 single chip microcomputer -- volatile keyword
2022-07-05 08:15:00 【chen_ bx】
volatile keyword
1. Application scenarios
volatile Keyword analysis , It is often used in three occasions
1) When multithreaded programming shares global variables , The global variable needs to be added with volatile To embellish , Let the compiler not optimize the variable .
2) During bare metal programming , When a function shares a global variable with an interrupt service function , The global variable needs to be added with volatile To embellish , Let the compiler not optimize the variable .
3)ARM When the register is defined , A register points to an address , To add volatile To embellish , Let the compiler omit access to the variable without optimization .
The compiler should not optimize this variable, which means to prevent the compiler from over Optimizing , Cause code operation failure .
add volatile The assembly code generated by keywords will change significantly , Also called delay function , The speed of the lamp changes !
2. Example
delay Function in -O2 Grade , Whether to add volatile keyword , Disassembly analysis .
边栏推荐
- Talk about the function of magnetic beads in circuits
- [tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
- C WinForm [view status bar -- statusstrip] - Practice 2
- Negative pressure generation of buck-boost circuit
- QEMU STM32 vscode debugging environment configuration
- MySQL之MHA高可用集群
- C language enhancement -- pointer
- Drive LED -- GPIO control
- My-basic application 1: introduction to my-basic parser
- Beijing Winter Olympics opening ceremony display equipment record 3
猜你喜欢
![C WinForm [view status bar -- statusstrip] - Practice 2](/img/40/63065e6c4dc4e9fcb3e898981f518a.jpg)
C WinForm [view status bar -- statusstrip] - Practice 2

Basic embedded concepts

Volatile of C language

Network communication model -- Network OSI tcp/ip layering
![Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine](/img/a1/d13b37955b044b6be5f1fd10263c5e.jpg)
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine

OC and OD gate circuit

FIO测试硬盘性能参数和实例详细总结(附源码)

H264 (I) i/p/b frame gop/idr/ and other parameters

Hardware and software solution of FPGA key chattering elimination

UEFI development learning 2 - running ovmf in QEMU
随机推荐
Sql Server的存储过程详解
Explain task scheduling based on Cortex-M3 in detail (Part 1)
Consul installation
Why is 1900 not a leap year
Network communication model -- Network OSI tcp/ip layering
Beijing Winter Olympics opening ceremony display equipment record 3
Hardware 1 -- relationship between gain and magnification
Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
Talk about the circuit use of TVs tube
Carrier period, electrical speed, carrier period variation
Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
QEMU STM32 vscode debugging environment configuration
Fundamentals of C language
Classic application of MOS transistor circuit design (2) - switch circuit design
Record the torch encountered by win10 cuda. is_ False problem in available()
STM32 virtualization environment of QEMU
Talk about the function of magnetic beads in circuits
Void* C is a carrier for realizing polymorphism
Charge pump boost principle - this article will give you a simple understanding
Drive LED -- GPIO control