 | bit OR & bit AND ~ bit NOT ^ bit EXLUSIVE OR (XOR) > bit RIGHT SHIFT.

Slides:



Advertisements
Similar presentations
CDA 3100 Recitation Week 10.
Advertisements

3-1 Peripherals & I/O lines All the on-chip peripherals are configured and controlled through Special Function Registers (SFR) Many of the SFR’s are bit.
Logic Symbols.
MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.
Programming Microcontrollers B. Furman 19MAR2011.
©Brooks/Cole, 2003 Chapter 4 Operations on Bits. ©Brooks/Cole, 2003 Apply arithmetic operations on bits when the integer is represented in two’s complement.
Programming the ATmega16
Assignment Operators =, +=, *= A += B means (A+B) --->A or A = (A+B) Similarly true for -=, *=, /=, and %=. The basic rule is from right to left. Never.
AVR Programming CS-212 Dick Steflik. ATmega328P I/O for our labs To get data into and out of our Arduino its a little trickier than using printf and.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Embedded Programming and Robotics Lesson 2 C Programming Refresher C Programming1.
Combinational Digital Circuits. Measurement Our world is an analog world. Measurements that we make of the physical objects around us are never in discrete.
Robotics Research Laboratory Louisiana State University.
In a not gate, if the input is on(1) the output is off (0) and vice versa.
You must be knowing about Digital Integrated Circuits (ICs) right ? For example 7404: Hex Inverter 7408: Quad 2-input AND gate 7410: Triple 3-input NAND.
Working with Arduino: Lesson #1: Getting Acquainted with the Kit EGN1007.
 C is general-purpose structured programming language or high level language.  It was developed by Dennis Ritchie in 1970s at Bell laboratories. 
Serial Communication ETEC 6416.
Bit Masking To access or affect only the bits we want, we need to construct a byte with bits set in the locations of interest – This byte is called a ‘bit.
1 Survey of Computer Science CSCI 110, Spring 2011 Lecture 16 Digital Circuits, binary Numbers.
Boolean math is the cornerstone of digital communications, whether you are talking computers, PLC, or Cisco Routers on the Internet. ©Emil Decker, 2009.
Binary Codes Computers and other digital systems "work" with binary numbers. I/P & O/P is usually done using decimal numbers, alphabetics, special symbols.
CS101 Introduction to Computing Lecture 8 Binary Numbers & Logic Operations.
XOR and XNOR Logic Gates. XOR Function Output Y is TRUE if input A OR input B are TRUE Exclusively, else it is FALSE. Logic Symbol  Description  Truth.
Click to edit Master title style Click to edit Master text styles –Second level Third level –Fourth level »Fifth level 1 Today’s Topics How information.
Computer Sensing and Control How is binary related to what we are trying to accomplish in electronics? The PC GadgetMaster II uses binary to communicate.
Synchronous Counters ET 5. Thinking back In the past we have seen that asynchronous counters can be used to count binary in the order that we have filled.
ECE 2372 Modern Digital System Design
Digital Logic Design Week 3
Number System. Number Systems Important Number systems – Decimal – Binary – Hexadecimal.
CMP 100 Introduction to Computing Lecture Binary Numbers & Logic Operations.
1 Ethics of Computing MONT 113G, Spring 2012 Session 1 Digital Circuits, binary Numbers Course webpage:
Projects 8051.
Chapter 4 Operations on Bits. Apply arithmetic operations on bits when the integer is represented in two’s complement. Apply logical operations on bits.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Bit Manipulation in 'C' 'C' bit operators
Microprocessor & Assembly Language
Programming in Arduino Materials:Arduino Board Casperelectronics Pre Pres. Notes Photos from workshop?
Atmega328p Introduction for Digital and PWM Output Brion L Fuller II Robotics Club.
ACOE161Digital Circuit Design1 Design Of Combinational Logic Circuits.
Windows Programming Lecture 06. Data Types Classification Data types are classified in two categories that is, – those data types which stores decimal.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
CMSC 202 Lesson 26 Miscellaneous Topics. Warmup Decide which of the following are legal statements: int a = 7; const int b = 6; int * const p1 = & a;
CompSci From bits to bytes to ints  At some level everything is stored as either a zero or a one  A bit is a binary digit a byte is a binary.
CS 111 – Aug. 27 Section 1.1 –Binary data and operations –Logic gates –Flip-flop –A binary shorthand: hexadecimal Commitment for next day: –Please read.
From bits to bytes to ints
Chapter 3 - Binary Numbering System
Chapter 4 Operations on Bits.
Chapter 2.3 Binary Logic.
Digital Signals Digital Signals have two basic states:
Fundamentals & Ethics of Information Systems IS 201
Session 3,4.
CENG2400 Revision Q1a A system has an ARM processor with a 32-bit General Purpose Input Output (GPIO) module. Two on/off switches are connected to bit-3.
Binary – Octal - Hexadecimal
Introduction to Programming
Working with Arduino: Lesson #1: Getting Acquainted with the Kit
REGISTER TRANSFER LANGUAGE
For OCR GCSE Computing Unit 1 - Theory
Bitwise Operators CS163 Fall 2018.
Homework Reading Tokheim, Section 5-10, 7-4.
Boolean Logic Boolean Logic is considered to be the basic of digital electronics. We know that a computer’s most basic operation is based on digital electronics.
ADC and DAC Programming in AVR
Design Example “Date of Birth Problem”
Lecture 5 Binary Operation Boolean Logic. Binary Operations Addition Subtraction Multiplication Division.
Multiplexing seven-segment displays
XOR Function Logic Symbol  Description  Truth Table 
靜夜思 床前明月光, 疑是地上霜。 舉頭望明月, 低頭思故鄉。 ~ 李白 李商隱.
Bit Manipulations CS212.
SYEN 3330 Digital Systems Chapter 2 – Part 1 SYEN 3330 Digital Systems.
Presentation transcript:

 | bit OR & bit AND ~ bit NOT ^ bit EXLUSIVE OR (XOR) > bit RIGHT SHIFT

 These operators work on bits and not logical values. Take two 8 bit bytes, combine with any of these operators, and you will get another 8 bit byte according to the operator's function. These operators work on the individual bits inside the byte. A truth table helps to explain each operation. In a truth table, a 1 bit stands for true, and a 0 stands for false.

 0 OR 0 = 0 0 OR 1 = 1 1 OR 0 = 1 1 OR 1 = 1  Symbol used : |  Example : | =

 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1  Symbol used : & Example : & =

 0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0  Symbol used: ^  Example : ^ =

 The NOT operator inverts the sense of the bit, so a 1 becomes a 0, and a 0 becomes a 1.  Symbol used: ~  Example: ~( )=

 To set pin 2:  (0x01 << 2)  To set pin 7:  (0x01 << 7)

 Internal peripherals send and receive information from the processor using registers.  Example: DDRX, PORTX, PINX, etc  X=A,B,C,D.

 // LED Blink Program using Software Delay  #include //header file containing in-built delay functions  #include //contains inbuilt input and output operations  void main()  {  DDRD = 0b ; // Make Port B as Output:   for(;;) // endless loop  {   PORTD = 0b ; // led ON  _delay_ms(100);  PORTD = 0b ; // led OFF  _delay_ms(100);  }

 So let's say I have a byte foo that is initialized to 0:  Code:  unsigned char foo = 0;  To set bit 0 in foo and then store the result back into foo:  Code:  foo = foo | ;  The OR operation is used between the variable that we want to change and a constant which is called a BIT MASK or simply the MASK. The mask is used to identify the bit that we want changed.  we can also write the constants in hexadecimal because it's shorter than writing it in binary

 How to Convert hexa decimal to binary and vice versa ???  foo |= 0x01;  To clear bit 0 in foo requires 2 bit operators:  foo = foo & ~0x01;  Again, the statement is made shorter as follows:  Code:  foo &= ~0x01;  There is another useful tool that is not often seen, and that is when you want to flip a bit, but you don't know and you don't care what state the bit is currently in, which you will be seeing at the end.

 // LED Blink Program using Software Delay  #include //header file containing in-built delay functions  #include //contains inbuilt input and output operations  void main()  {  DDRD = 0b ; // Make Port B as Output:   for(;;) // endless loop  {   PORTD| = 0b ; // led ON (except pin 7 rest all are masked )  _delay_ms(100);  PORTD &= 0b ; // led OFF (except pin 7 rest all are masked)  _delay_ms(100); }  }

 // LED Blink Program using Software Delay  #include //header file containing in-built delay functions  #include //contains inbuilt input and output operations  void main()  {  DDRD = 0b ; // Make Port B as Output:  PORTD=0b ;  for(;;) // endless loop  {   PORTD^=0b ;  _delay_ms(100); }  }