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.

a problem in programming an avr with c

Status
Not open for further replies.

m_pourfathi

Full Member level 4
Joined
Feb 7, 2008
Messages
200
Helped
17
Reputation
34
Reaction score
3
Trophy points
1,298
Activity points
2,579
lbbl_endian_int

I don't understand what does these macros mean please help:

#define ETH_INT_ENABLE GICR |= (1<<INT2)

#define ENC28J60_CS_HI() ENC28J60_PORT |= (1<<ENC28J60_PIN_CS);

#define ENC28J60_REG_MAADR2 (0x63 | 0x80)

#define ENC28J60_TX_BUFFER_START ((unsigned int)0x1A00)

#define LO8(x) ((x)&0xFF)

#define LBBL_ENDIAN_INT(x) ((x & 0x00FF) << 8 ) + ((x & 0xFF00) >> 8 )

#define LBBL_ENDIAN_LONG(x) ((x & 0xFF000000) >> 24) + ((x & 0x00FF0000) >> 8 ) + ((x & 0x0000FF00) << 8 ) + ((x & 0x000000FF) << 24)

thanks
 

avr c left shift

#define is a text pattern replacement directive.
from your example
#define LBBL_ENDIAN_INT(x) ((x & 0x00FF) << 8 ) + ((x & 0xFF00) >> 8 )

when compiling the complier will replace every
LBBL_ENDIAN_INT(x)
with
((x & 0x00FF) << 8 ) + ((x & 0xFF00) >> 8 )
before compiling
so after this #define you can write
LBBL_ENDIAN_INT(x) which easier to understand than
((x & 0x00FF) << 8 ) + ((x & 0xFF00) >> 8 )
 

lbbl_endian_long

I know, but what exactly is the meaning of the second part? I don't understand that part! :(
 

avr bitwise left shift c

Below is the assumption from me but for a better solution just type the complete line of the code where it is used.

actually here & is logical 'AND' operator which perfoms logical and operations on the two variables here it is x and 0x00FF or 0xFF00

And >>, << are bitwise operators which shifts the bits to the right or left in binary base, here it will do that 8 times, i.e. left shift 8 times and right shift by 8 times.

I think the statement is used to logical and the two variables, value of the x with
0x00FF and 0xFF00 then it performs the left shift and right shift 8 times whatever the value is.

Actually in binary each right shift devides the number by 2 and each left shift multiplies the number by 2.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top