当前位置:网站首页>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 .
边栏推荐
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
- Network port usage
- Negative pressure generation of buck-boost circuit
- Buildroot system for making raspberry pie cm3
- Makefile application
- Imx6ull bare metal development learning 1-assembly lit LED
- Consul安装
- General makefile (I) single C language compilation template
- UEFI development learning 3 - create UEFI program
- Class of color image processing based on Halcon learning_ ndim_ norm. hdev
猜你喜欢
UEFI development learning 6 - creation of protocol
生产中影响滑环质量的因素
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
C WinForm [change the position of the form after running] - Practical Exercise 4
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
C WinForm [view status bar -- statusstrip] - Practice 2
Working principle and type selection of common mode inductor
Semiconductor devices (III) FET
QEMU STM32 vscode debugging environment configuration
随机推荐
Hardware 1 -- relationship between gain and magnification
Negative pressure generation of buck-boost circuit
【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
C WinForm [help interface - send email] - practice five
General makefile (I) single C language compilation template
Slist of linked list
C WinForm [change the position of the form after running] - Practical Exercise 4
UEFI development learning 3 - create UEFI program
Detailed explanation of pragma usage
VESC Benjamin test motor parameters
Buildroot system for making raspberry pie cm3
Classic application of MOS transistor circuit design (2) - switch circuit design
Problem solving: interpreter error: no file or directory
FIO测试硬盘性能参数和实例详细总结(附源码)
UEFI development learning 4 - getting to know variable services
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine
Arduino uses nrf24l01+ communication
Compilation warning solution sorting in Quartus II
Basic embedded concepts
Step motor generates S-curve upper computer