Doubt regarding the volatile keyword

Status
Not open for further replies.

Goran_

Newbie level 3
Joined
Jun 5, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,304
(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 typecasts to volatile unsigned long pointer. But (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00)) , what is for the starting star(dereferencing operator) after first bracket.
 

If I am wrong then correct me.

#define PINSEL_BASE_ADDR 0xE002C000

means PINSEL_BASE_ADDR is given the value 0xE002C000

PINSEL_BASE_ADDR holds some base address 0xE002C000

(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00) means

you are making the memory location 0xE002C000 + 0x00 as a pointer to volatile unsigne long type. It means the address stored at address 0xE002C000 points to a volatile unsigned long integer.

#define PINSEL0 (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00)) means you are dereferencing (volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00) to get the volatile unsigned long int value pointed to by the pointer and making it an alias for PINSEL0
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…