Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Silly question, I'm sure for ATmega8 WinAVR

2008-01-25 by englsprogeny

I understand bitwise operations but I don't get the following code.

DDRB|= (7<<3)

I understand that this is to setup the direction for port B  BUT why
are we doing [what appears to be] 7 shifted to the left 3 times
instead of 56 decimal

Is this the same?

DDRB|= (56)

OR are we shifting just the 7th bit left three times?  I saw in the
ATmega8 datasheet that the DDR registers are 8 bit.  Can you shift bit
7 left 3 times?


Heres's another one:

PORTB=PORTB|(1<<DDB5)

Why wouldn't we just say?

PORTB=PORTB|(DDB5)

or

PORTB=PORTB|(32)

I am new to AVR and WinAVR.

Where can I learn this information?   [books /internet/ datasheeets]

Thank you for your inputs.

David

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.