Doubt regarding the volatile keyword

This is a discussion on Doubt regarding the volatile keyword within the C Programming forums, part of the General Programming Boards category; What i understood is (1)volatile unsigned char * ADC_address; ---ADC_address is a pointer which stores a volatile unsigned character . ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    3

    Doubt regarding the volatile keyword

    What i understood is
    (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.

    What i don't understood is
    (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.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    Your first three points are correct.

    Quote Originally Posted by 2001goran View Post
    (*(volatile unsigned long *)(PINSEL_BASE_ADDR + 0x00)) , what is for the starting star(dereferencing operator) after first bracket.
    You already know what it is - it's the dereferencing operator. This statement is saying "take PINSEL_BASE_ADDR, cast it to be a volatile unsigned long pointer, and then dereference it to give the unsigned long located there". In other words, using "PINSEL0" in your code read the value at PINSEL_BASE_ADDR (i.e. at 0xE002C000).
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

    ~~~

    "The largest-scale pattern in the history of Unix is this: when and where Unix has adhered most closely to open-source practices, it has prospered. Attempts to proprietarize it have invariably resulted in stagnation and decline."

    Eric Raymond, The Art of Unix Programming

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. To Volatile, or not to Volatile?
    By EVOEx in forum C++ Programming
    Replies: 16
    Last Post: 05-12-2012, 02:07 PM
  2. Volatile Variables
    By Gauravmore in forum C Programming
    Replies: 4
    Last Post: 01-11-2011, 07:29 AM
  3. Volatile Keyword!!
    By maven in forum C Programming
    Replies: 8
    Last Post: 12-06-2005, 11:56 AM
  4. volatile??
    By jacktibet in forum C Programming
    Replies: 2
    Last Post: 05-29-2003, 03:46 PM
  5. volatile keyword help!!!!
    By penney in forum Linux Programming
    Replies: 2
    Last Post: 03-12-2003, 07:09 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21