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.

Reading/writing register using macros in a single line in C

Status
Not open for further replies.

shaikss

Full Member level 4
Joined
Jun 18, 2007
Messages
229
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
3,319
Hi,

I want to read/write a register using C.
Its easy by using pointers.
But read/write by using macros in a single line.
Just by using a single line without pointers, it has to read/write the value from the register.
Can you pls help me..........

Thanks
Shabana
 

Re: Help in C

Hi,

Define a macro with the address of the SFR. and use the macro name when u read and write to a register
 

Re: Help in C

For example One of the register is located at location 0xFFFF0000.
I want to write 0xFFFFF into the register.
Can u tell me the sample code for this.
 

Re: Help in C

with out pointer we cannot do
 

Help in C

Assuming the register is 16 bits wide, and your compiler's short integer is 16 bits wide:

*(volatile short*)0xFFFF0000 = 0xFFFF;
 

Re: Help in C

With register level programming you have to learn pointers
 

Re: Help in C

Depends on the compiler. Some like Keil allow you to assign a variable to an address and then you can just use that variable
 

Help in C

yuuup just define them...
 

Help in C

This should work...

#define RegisterName (*((volatile unsigned long *) 0xFFFF0000))

RegisterName = 0x000FFFFF;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top