Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Defining memory location in Embedded C

Status
Not open for further replies.

shiva

Junior Member level 3
Junior Member level 3
Joined
Oct 18, 2005
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,537
help in C

i want to define memory location with my own name.AS it done in case of control register or tomer or SRF.

can i do that in Embedded C.
i m working on 8051.
 

Re: help in C

That's not defined in the c standard. So each compiler makes that a bit different. Look in your manual to your compiler. It's explained there and I'm sure there are also some examples. Look also in the header file to your controller. Mostly there are defined all important registers.

Gomez
 

help in C

Yes, you can do it using pointers

e.g.

unsigned char *shiva = someaddress;
#define SHIVA (*shiva)

Then you can use it as:

SHIVA = 0x55;
*shiva = 0x55;


Is this you are looking for?
 

Re: help in C

I think u should use pointers but do not forget the keword volatile.
Regards,
Amraldo.
 

Re: help in C

dipal_z said:
Yes, you can do it using pointers

e.g.

unsigned char *shiva = someaddress;
#define SHIVA (*shiva)

Then you can use it as:

SHIVA = 0x55;
*shiva = 0x55;


Is this you are looking for?

This construct needs initialisation time. :cry:

That's the reason why in the delivered header files all registers are defined so:

#pragma ADDRESS U0MR 3A0h // UART 0 mode register
sfr U0MR = 0x3A0; /* UART 0 mode register */

but that's depend from your compiler.

Gomez
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top