当前位置:网站首页>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 .
边栏推荐
- Shell脚本基本语法
- Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
- Talk about the circuit use of TVs tube
- UEFI development learning 2 - running ovmf in QEMU
- Summary -st2.0 Hall angle estimation
- Installation and use of libjpeg and ligpng
- Consul安装
- Summary of SIM card circuit knowledge
- MySQL之MHA高可用集群
- Makefile application
猜你喜欢
Interview catalogue
Stablq of linked list
DokuWiki deployment notes
导电滑环磨损快的原因
Step motor generates S-curve upper computer
Connection mode - bridge and net
[untitled] record the visual shock of the Winter Olympics and the introduction of the display screen
Introduction of air gap, etc
MySQL之MHA高可用集群
Summary of SIM card circuit knowledge
随机推荐
Detailed explanation of SQL server stored procedures
Vofa+ software usage record
Some thoughts on extracting perspectives from ealfa and Ebeta
matlab timeserise
How to copy formatted notepad++ text?
Volatile of C language
Talk about the circuit use of TVs tube
OLED 0.96 inch test
Create inf module in AMI code
Bluetooth hc-05 pairing process and precautions
Soem EtherCAT source code analysis II (list of known configuration information)
Working principle and type selection of common mode inductor
Adaptive filter
Solutions to compilation warnings in Quartus II
C language # and #
Programming knowledge -- assembly knowledge
Extern keyword function
Correlation based template matching based on Halcon learning [II] find_ ncc_ model_ defocused_ precision. hdev
Process communication mode between different hosts -- socket
DCDC circuit - function of bootstrap capacitor