[email protected] wrote:
> Hi Friends,
> 
> I have defined  a variable in file1.h as
> 
> #define BASE (0x00800000) // address of BASE
> 
> and i defined a pointer to the same variable as in file2.h
> 
> #define base_ptr  (volatile uint *) BASE)
> 
> Now my requirement is i have to change the following statements by
> using the base_ptr which i defined in file2.h 
> 
>   *((volatile uint *) 0x00850000) = 0x000a0041;     
>   *((volatile uint *) 0x00850004) = 0x00870000;
> 
> can i do like this
> 
>  *((volatile uint *) (ibuf_base_ptr+0x50000))= 0x000a0041;             
>  *((volatile uint *) (ibuf_base_ptr+0x50004))= (ibuf_base_ptr+70000);
> 
> I tried in so many ways but didn't get it.
> Can you please help me .
> With Regards,
> ss...
> 

I do this type of stuff a lot for accessing hardware registers (real time 
machine control applications) and here is an example of how I do it:

#define BASE_ADDRESS     0x01000
#define SYSTEM_CONTROL_REGISTER  *((unsigned char far *)(BASE_ADDRESS + 0x22))

To read from the register:
unsigned char  temp;
temp = SYSTEM_CONTROL_REGISTER;

To write to the register:
SYSTEM_CONTROL_REGISTER = <value that you want to write>;


In your case, this is what I would do (change the names to something more 
meaningful:

#define BASE (0x00800000)
#define REGISTER1 *((volatile uint *) (BASE+0x50000))
#define REGISTER2 *((volatile uint *) (BASE+0x50004))

REGISTER1 = 0x000a0041;
REGISTER2 = 0x00870000;





To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/c-prog/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/c-prog/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to