6
SINGLE BIT OPRATIONS IN AVR MICROCONTROLLER ROBO INDIA PRESENTATION ON

Single bit oprations in avr microcontroller

Embed Size (px)

Citation preview

Page 1: Single bit oprations in avr microcontroller

SINGLE BIT OPRATIONSIN

AVR MICROCONTROLLER

ROBO INDIAPRESENTATION ON

Page 2: Single bit oprations in avr microcontroller

If you have forgotten

AND – Multiply OR – ADD

AND & OR OPERATIONS

Page 3: Single bit oprations in avr microcontroller

#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))

• Understanding (1<<BIT)

• 1 = 00000001

• BIT = any = 4(Ex)

• 1<<4 = 00000001<<4 (1 is left shifted 4 times)

• (1<<BIT) = 00010000

SET A BIT

Page 4: Single bit oprations in avr microcontroller

#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))

• ADDRESS = PORTX = 00100100 (suppose)

• ADDRESS |= (1<<BIT))

⇒ ADDRESS = ADDRESS | (1<<BIT)

• ADDRESS | (1<<BIT) 00100100 | 00010000⇒

• Updated ADDRESS = 00110100

SET A BITClick here to visit -ROBO INDIA

Page 5: Single bit oprations in avr microcontroller

#define CLEARBIT(ADDRESS,BIT) (ADDRESS &=~ (1<<BIT))

• ADDRESS = PORTX = 00110100 (suppose)

• ADDRESS &= ~(1<<BIT))

⇒ ADDRESS = ADDRESS & INVERTED(1<<BIT)

• ADDRESS & ~ (1<<BIT) 00110100 & 11101111⇒

• Updated ADDRESS = 00100100

CLEAR A BITClick here to visit -ROBO INDIA

Page 6: Single bit oprations in avr microcontroller

THANKS & REGARDSTEAM ROBO INDIA

To share your views and queries please write us-

Website: http://roboindia.comEmail- [email protected]

Click here to visit -ROBO INDIA