#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep 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.
  2. #2
  3. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,117
    Rep Power
    1803
    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?).

IMN logo majestic logo threadwatch logo seochat tools logo