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.

Keil Compiler and Unions

Status
Not open for further replies.

nrmlguru

Newbie level 4
Joined
Jan 25, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,310
Hello,

I have the following code.
I want to define a PORTA at address 0x80;
and then write an 8 bit data to PORTA.
I am not getting the expected result.

typedef union {
byte Byte;
struct {
byte BIT0 :1;
byte BIT1 :1;
byte BIT2 :1;
byte BIT3 :1;
byte BIT4 :1;
byte BIT5 :1;
byte BIT6 :1;
byte BIT7 :1;
} Bits;
} PORTASTR;
PORTASTR *_PORTA=(PORTASTR *)0x80;

#define PORTA _PORTA->Byte


void main()
{
unsigned int i;

while(1)
{
for(i=1000; i>0; i--);
PORTA = 0xFF;
for(i=1000; i>0; i--);
PORTA = 0x00;

}
}
 

its already defined by the manufacturer in the startup code.. it will not allow you to redifne.. you may get error that you are re-defining.................
 

Hello Shivaram,

No it doesn't through an error. But am not seeing address location 0x80 changing.
I want to create my own library for all the hardware registers.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top