C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 14th, 2013, 07:53 AM
2001goran 2001goran is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 2001goran User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 43 sec
Reputation Power: 0
Doubt regarding the volatile keyword

What i understood about volatile keyword

(1)volatile unsigned char * ADC_address;
ADC_address is a pointer which stores a volatile unsigned character .

(2)volatile unsigned int ADC_voltage = 0;
ADC_voltage is volatile unsigned integer variable ,

(3)volatile unsigned char * ADC_REAL_ADDRESS;
ADC_REAL_ADDRESS = (volatile unsigned char *)STA_MEMORY_BASE;
Typecasting STA_MEMORY_BASE to volatile unsigned char pointer and assigned to ADC_REAL_ADDRESS.

If I wrong means please correct me.


(4)Can anyone explain the below statements
#define PINSEL_BASE_ADDR 0xE002C000
#define PINSEL0 (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00))

what I understood is (volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00) in this statement (PINSEL_BASE_ADDR + 0x00) is type casted to volatile unsigned long pointer. But (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00)) , what is for the starting star(dereferencing operator) after first bracket.

Reply With Quote
  #2  
Old March 14th, 2013, 10:06 AM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,808 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 17 h 42 m 37 sec
Reputation Power: 1800
The definition:
Code:
#define PINSEL0 (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00))

Takes the base address and dereferences it. Allowing you to write code such as:
Code:
PINSEL0 = 1 ;


The +0x00 offset has no effect of course but is presumably used to be consistent with the definitions of other registers (PINSEL1 perhaps?).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Doubt regarding the volatile keyword

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap