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
Joined
Jul 1, 2008
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,398
avr pinb

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
 

help on avr programming

PINB and PB2 are macros. In some of the header files you are including, there are definitions for PINB and PB2; for example, if you are using avr-gcc, you are including iom32.h (via io.h), which contains:

#define PINB _SFR_IO8(0x16)

and

#define PB2 2


JW
 

help on avr programming

Hi mehipour:
I think the whole word is
" if (PINB &(1<<PB2)) == 0) "
it means if PB2 is equal to 0(PB2 is low).
In ICCAVR, to get a status of a IO(eg.PB2), you can read register PINX(eg.PINB), but the value consist of all PINX(8 bits), so you must dispose of some bits, "&(1<<PB2)" is used for that job.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top