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.

help on avr programming - problem with C syntax

Status
Not open for further replies.

mehipour

Junior Member level 2
Junior Member level 2
Joined
Jul 1, 2008
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,398
help on avr programming

hi folks,

I programming AVR ATmega32 for an embedded web-server. There's this C language Syntax that I have confronted and I don't understand.

(PINB &(1<<PB2)) == 0)

I didn't fully understand the meaning of this syntax. I suppose that PINB is the portb register and PB2 is the third bit of this port which is used as an interrupt.
thanks a lot,

Mehipour
 

Re: help on avr programming

Hi,

PINB and PB2:
I think there must be a #define statement thats define PINB and PB2.
 

Re: help on avr programming

They are both defined in the header files. Let me rephrase my question. Imagine we know what are PINB and PB2 both are! Now by this assumption what this syntax will do? That's what I need to know please.
Actually the real syntax is

while((PINB &(1<<PB2)) == 0))
{// statement};

I need to when the statement is going to run by the program. What exactly is the condition?

Thanks,
 

Re: help on avr programming

PINB has the logic states of PORTB pins.
1<<PB2=0b00000100, is the mask
So while will be executed as long as the PB2 pin of PORTB is 0.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top