> Jim Dougherty <[ mailto:j_dougherty%40ecrm.com [EMAIL PROTECTED]> wrote: [ > mailto:c-prog%40yahoogroups.com [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 = ; > > 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; > [email protected] wrote: > Hi Jim Dougherty and friends, > > Thank you so much for your mail. > > Actually this "BASE" is not a register it is a memory location. > > I am actually new to C. > > Then can i do like this. > > In file1.h i will define > > #define BASE (0x00800000) // address of BASE > > In file2.h i will define > > #define base_ptr ((volatile unsigned char *)BASE) > > then i will change the following statements as > >> *((volatile uint *) 0x00850000) = 0x000a0041; >> *((volatile uint *) 0x00850004) = 0x00870000; > > *BASE+0x50000 = 0x000a0041; > *BASE+0x50004 = *BASE+70000; > > Please kindly help me... > > I must define a base_ptr in file2.h and then i should be able to use it. > > I will be waiting for your reply. > > Thanks & Regards, > SS... When I said hardware register, I should have said memory mapped hardware register. You can think of this as no different than any other memory location in terms of its ability to be read from and written to. Given this, I am pretty sure that the approach I laid out for you will work just fine. 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/
