当前位置:网站首页>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 .
边栏推荐
- C WinForm [change the position of the form after running] - Practical Exercise 4
- LED display equipment records of the opening ceremony of the Beijing Winter Olympics
- DCDC circuit - function of bootstrap capacitor
- The firmware of the connected j-link does not support the following memory access
- 生产中影响滑环质量的因素
- Volatile of C language
- Soem EtherCAT source code analysis I (data type definition)
- Semiconductor devices (I) PN junction
- Halcon's practice based on shape template matching [2]
- Solutions to compilation warnings in Quartus II
猜你喜欢
UEFI development learning 5 - simple use of protocol
Explain task scheduling based on Cortex-M3 in detail (Part 1)
Introduction of air gap, etc
1-stm32 operation environment construction
Makefile application
[paper reading] the latest transfer ability in deep learning: a survey in 2022
FIO测试硬盘性能参数和实例详细总结(附源码)
Record the visual shock of the Winter Olympics and the introduction of the screen 2
The firmware of the connected j-link does not support the following memory access
Connection mode - bridge and net
随机推荐
Explication de la procédure stockée pour SQL Server
Imx6ull bare metal development learning 2- use C language to light LED indicator
OLED 0.96 inch test
Drive LED -- GPIO control
Tailq of linked list
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
Relationship between line voltage and phase voltage, line current and phase current
Screen record of the opening ceremony of the Beijing winter olympics 2
Some thoughts on extracting perspectives from ealfa and Ebeta
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
Synchronization of QT multithreading
Verilog -- state machine coding method
OC and OD gate circuit
C WinForm [display real-time time in the status bar] - practical exercise 1
Working principle and type selection of common mode inductor
Semiconductor devices (I) PN junction
Wifi-802.11 negotiation rate table
What are the test items of power battery ul2580
PMSM dead time compensation
C WinForm [help interface - send email] - practice five