当前位置:网站首页>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 .
边栏推荐
- Explain task scheduling based on Cortex-M3 in detail (Part 1)
- Interview catalogue
- Soem EtherCAT source code analysis I (data type definition)
- Extern keyword function
- 生产中影响滑环质量的因素
- Halcon's practice based on shape template matching [1]
- [trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
- Why is 1900 not a leap year
- Wifi-802.11 negotiation rate table
- Imx6ull bare metal development learning 1-assembly lit LED
猜你喜欢
![C WinForm [exit application] - practice 3](/img/25/30c795cc3fa6931eb1d733719d4ad0.jpg)
C WinForm [exit application] - practice 3

Let's briefly talk about the chips commonly used in mobile phones - OVP chips

Factors affecting the quality of slip rings in production

Consul安装

Shell脚本基本语法

Communication standard -- communication protocol

MySQL之MHA高可用集群

Record the visual shock of the Winter Olympics and the introduction of the screen 2

Connection mode - bridge and net

Network communication model -- Network OSI tcp/ip layering
随机推荐
Void* C is a carrier for realizing polymorphism
1-stm32 operation environment construction
How to copy formatted notepad++ text?
Bootloader implementation of PIC MCU
Detailed explanation of SQL server stored procedures
General makefile (I) single C language compilation template
UEFI development learning 4 - getting to know variable services
Record the opening ceremony of Beijing Winter Olympics with display equipment
Basic embedded concepts
FIO测试硬盘性能参数和实例详细总结(附源码)
Naming rules for FreeRTOS
C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
Network communication model -- Network OSI tcp/ip layering
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
OLED 0.96 inch test
Network port usage
PMSM dead time compensation
Live555 push RTSP audio and video stream summary (I) cross compilation
Classic application of MOS transistor circuit design (2) - switch circuit design
Hardware and software solution of FPGA key chattering elimination