当前位置:网站首页>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 .
边栏推荐
- OLED 0.96 inch test
- Measurement fitting based on Halcon learning [II] meaure_ pin. Hdev routine
- Extern keyword function
- C WinForm [view status bar -- statusstrip] - Practice 2
- C # joint configuration with Halcon
- Consul installation
- [tutorial 15 of trio basic from introduction to proficiency] trio free serial communication
- Semiconductor devices (III) FET
- Measurement fitting based on Halcon learning [III] PM_ measure_ board. Hdev routine
- UEFI development learning 2 - running ovmf in QEMU
猜你喜欢

Explain task scheduling based on Cortex-M3 in detail (Part 1)

FIO测试硬盘性能参数和实例详细总结(附源码)

How to copy formatted notepad++ text?

Stablq of linked list

Carrier period, electrical speed, carrier period variation

Consul installation
![Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine](/img/a1/d13b37955b044b6be5f1fd10263c5e.jpg)
Shape template matching based on Halcon learning [v] find_ cocoa_ packages_ max_ deformation. Hdev routine

Record the opening ceremony of Beijing Winter Olympics with display equipment

Communication standard -- communication protocol

导电滑环磨损快的原因
随机推荐
Process communication mode between different hosts -- socket
Network communication process
Arduino uses nrf24l01+ communication
Basic embedded concepts
My-basic application 2: my-basic installation and operation
Relationship between line voltage and phase voltage, line current and phase current
How to define guid in AMI code
Slist of linked list
Consul installation
Drive LED -- GPIO control
Gradle composite construction
List of linked lists
Record the opening ceremony of Beijing Winter Olympics with display equipment
Volatile of C language
My-basic application 1: introduction to my-basic parser
Imx6ull bare metal development learning 2- use C language to light LED indicator
UEFI development learning 5 - simple use of protocol
C WinForm [display real-time time in the status bar] - practical exercise 1
[paper reading] the latest transfer ability in deep learning: a survey in 2022
Classic application of MOS transistor circuit design (2) - switch circuit design