Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

The usage of volatile and its difference from const volatile

Status
Not open for further replies.

raja.bhavanam

Junior Member level 3
Junior Member level 3
Joined
Nov 22, 2005
Messages
28
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,502
volatile unsigned short emif

what are the uses of volatile and what is the difference between
volatile and const volatile ?
 

Re: uses of volatile

Look here:


I va never seen const volatile ...

best regards
 


uses of volatile

volatile means that something else besides your code can modify the object.
The C standard says: an object that has volatile-qualified type may be modified in ways unknown to the implementation or have other unknown side effects.

const volatile means that your code can't modify the object but something else can.
The C standard gives an example:
extern const volatile int real_time_clock;
may be modifiable by hardware, but cannot be assigned to, incremented, or decremented.
 
Re: uses of volatile

Hallo all,
just to give a practical example: I'm working on a custom board with a DSP of C64xx family by Texas Instruments, which interfaces with an external custom bus through a set of 16-bit registers implemented in a FPGA connected to the DSP EMIF.
The DSP is programmed in C/C++ and to access to the FPGA registers I declared a set of pointers of the type

volatile unsigned short * register_xx

I must use this type declaration for 2 reasons:
1) registers on FPGA are written by other devices connected to the external bus
2) Code Composer Compiler sometimes (very often) interprets these registers as variables that don't change (because changes are made outside the SW) and so it discard from the compiled executable code and nothing works as expected.

I hope this example will help to understand.

Bye
Mowglii
 
Re: uses of volatile


Hi
Both volatile and const volatile **broken link removed** are valid qualifiers in c language.

for your info let me explain it by a simple example

Say you have two programs p1 and p2 and you have declared a variable x as volatile and y as const volatile. Now just simply x can be changed or altered by p1 as well by p2 however y can be altered by p2 but not by p1 .

The application of this declaration is that the ports in microcontrollers are declared as constant volatile.


**broken link removed**
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top