当前位置:网站首页>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 .
边栏推荐
- UEFI development learning 3 - create UEFI program
- Talk about the function of magnetic beads in circuits
- Consul安装
- [trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
- STM32 virtualization environment of QEMU
- Anonymous structure in C language
- Keil use details -- magic wand
- Stablq of linked list
- 动力电池UL2580测试项目包括哪些
- Take you to understand the working principle of lithium battery protection board
猜你喜欢
[cloud native | learn kubernetes from scratch] III. kubernetes cluster management tool kubectl
Classic application of MOS transistor circuit design (2) - switch circuit design
C WinForm [change the position of the form after running] - Practical Exercise 4
【论文阅读】2022年最新迁移学习综述笔注(Transferability in Deep Learning: A Survey)
H264 (I) i/p/b frame gop/idr/ and other parameters
DokuWiki deployment notes
Shell脚本基本语法
Halcon's practice based on shape template matching [2]
[trio basic from introduction to mastery tutorial XIV] trio realizes unit axis multi-color code capture
Design a clock frequency division circuit that can be switched arbitrarily
随机推荐
1-stm32 operation environment construction
Ble encryption details
Embedded composition and route
Measurement fitting based on Halcon learning [i] fuse Hdev routine
Some tips for using source insight (solve the problem of selecting all)
Shape template matching based on Halcon learning [viii] PM_ multiple_ models. Hdev routine
C language enhancement -- pointer
Explain task scheduling based on Cortex-M3 in detail (Part 2)
C WinForm [help interface - send email] - practice five
Imx6ull bare metal development learning 1-assembly lit LED
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
STM32 virtualization environment of QEMU
Factors affecting the quality of slip rings in production
Talk about the function of magnetic beads in circuits
Live555 push RTSP audio and video stream summary (III) flower screen problem caused by pushing H264 real-time stream
UEFI development learning 3 - create UEFI program
Relationship between line voltage and phase voltage, line current and phase current
Network communication model -- Network OSI tcp/ip layering
Shell script realizes the reading of serial port and the parsing of message
Wifi-802.11 negotiation rate table