modidied.ppt
-
Upload
vishal-lalit -
Category
Documents
-
view
212 -
download
0
Transcript of modidied.ppt
![Page 1: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/1.jpg)
Department of ELECTRONICS & COMMUNICATION Engineering
JCD College of Engineering, Sirsa
ASUMMER TRAINING REPORT
ON
EMBEDDED SYSTEM
SUBMITTED TO: - SUBMITTED BY:-Mr. Vinod Kumar Diksha,Sangam,Priyanka
![Page 2: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/2.jpg)
Electronics is the branch of science which deals with the behavior of electron under the influence of electric and magnetic field.•Started with development of telegraph in late 19th century. •Applications:
•Radio•Television•RADAR •Computer
ELECTRONICS
![Page 3: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/3.jpg)
TYPES OF ELECTRONIC CIRCUIT
•Analog circuit. They use a continuous range of voltage.
•Digital Circuit. They are based on a number of discrete voltage levels.
![Page 4: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/4.jpg)
EMBEDDED SYSTEM
•“An embedded system is one that has a dedicated purpose software embedded in a computer hardware”.
•It processes a fixed set of pre-programmed instructions to control electromechanical equipment which may be part of an even larger system
![Page 5: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/5.jpg)
DIFFERENCE BETWEEN PERSONAL COMPUTER AND EMBEEDED SYSTEM
PERSONAL COMPUTER EMBEDDED SYSTEM
General purpose system Single purpose
Always having a user interface
Less or no user interface
Slow in operation Faster than pc
Larger in size Smaller in size
Power consuming Requires less power
![Page 6: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/6.jpg)
TYPICAL EMBEDDED SYSTEM
![Page 7: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/7.jpg)
CHARACTERISTICS OF EMBEDDED SYSTEMS
•Embedded systems are application specific & single functioned.•Efficiency is of paramount importance for embedded systems •Embedded systems often interact (sense, manipulate & communicate) with external world through sensors and actuators •They generally have minimal or no user interface.
![Page 8: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/8.jpg)
EMBEDDED SYSTEM DESIGN
•Requirement analysis. •Defining the system specifications. •Modeling the system to be designed. •HW-SW partitioning. •Selection of technology. •Resource Analysis – Cost, Time & Manpower.•Identification of components and development tools. •Circuit design/ Schematic Capture, PCB layout design & fabrication. • testing. •System Integration. •Testing – functional, environmental
![Page 9: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/9.jpg)
ELECTRONIC COMPONENTS
•Resistor•Capacitor•Diode•Switches•LED•Seven segment display•LCD•Relay
![Page 10: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/10.jpg)
RESISTOR
•It is a electrical component that limits the flow of electric current in the circuit.•Tendency to oppose electric current.•Resistor is a passive component used to control current in a circuit.•The resistance is given by the ratio of voltage applied across the terminals to the current passing through it.
![Page 11: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/11.jpg)
CAPACITOR•Capacitor is a passive component used to store charge.•The charge (q) stored in a capacitor is the product of its capacitance (C) value and the voltage (V) applied to it.Q=C*V •It stores electric charge and then discharges it into the circuit. •It blocks the direct current and allows the alternating current to pass through it. •The unit of capacitance is FARAD. •A capacitor contains two conductor plates which are generally made of metal and an insulator between them.
![Page 12: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/12.jpg)
DIODE
•A diode is a unipolar device. •Diode is a rectifying device which conducts only from anode to cathode. •Diode behaves open circuited for the current flow from cathode to anode. •When forward biased there is a small amount of voltage necessary to get the diode going.•When reverse biased an ideal diode will block current.•If enough voltage (reverse) is applied, and junction breaks down and lets current pass through.
![Page 13: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/13.jpg)
SWITCH
•Used to make or break electronic circuit.
![Page 14: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/14.jpg)
LED (LIGHT EMMITING DIODE)
•Light emitting diodes (LEDs) are semiconductor light sources. •The light emitted from LEDs varies from visible to infrared and ultraviolet regions. •They operate on low voltage and power. •They are mostly used as indicators in circuits. •Based on semiconductor diode, LEDs emit photons when electrons recombine with holes on forward biasing.
![Page 15: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/15.jpg)
WORKING OF LED
![Page 16: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/16.jpg)
![Page 17: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/17.jpg)
![Page 18: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/18.jpg)
SEVEN SEGMENT DISPLAY
•A seven segment display is the most basic electronic display device that can display digits from 0-9. •The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. •They are laid out as a squared-off figure ‘8’. •Every LED is assigned a name from 'a' to 'h' and is identified by its name. •LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used to display the dot/decimal.
![Page 19: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/19.jpg)
•These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA).
•In CC configuration, the negative terminals of all LEDs are connected to the common pins.
•In CA arrangement, the common pin is given a high logic and the LED pins are given low to display a number.
![Page 20: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/20.jpg)
LCD (LIQUID CRYSTAL DISPLAY)•LCD (Liquid Crystal Display) screen is an electronic display module.•A 16x2 LCD display is very basic module.•LCDs are economical. •Easily programmable. •A 16x2 LCD means it can display 16 characters per line and there are 2 such lines.•This LCD has 2 resistors, namely command and data.•The command resistor stores the command instructions given to the LCD.•The data resistor stores the data to be displayed on the LCD.
![Page 21: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/21.jpg)
PIN DIAGRAM OF LCD
![Page 22: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/22.jpg)
DC Motor. Stepper Motor. Transistors. Voltage Regulators. H-Bridge
![Page 23: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/23.jpg)
•A simple device that converts electrical energy into mechanical energy. •DC motors have a rotating armature winding (winding in which a voltage is induced) but Non-rotating armature magnetic field and a static field winding (winding that produce the main magnetic flux) or permanent magnet.
![Page 24: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/24.jpg)
![Page 25: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/25.jpg)
•A stepper motor (or step motor) is a brushless DC electric motor that divides a full rotation into a number of equal steps. •The motor's position can then be commanded to move and hold at one of these steps without any feedback sensor. •As all motors, the stepper motors consists of a stator an a rotor. .
![Page 26: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/26.jpg)
•To make the motor shaft turn, first, one electromagnet is given power, which magnetically attracts the gear's teeth. •When the gear's teeth are aligned to the first electromagnet, they are slightly offset from the next electromagnet. •So when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to align with the next one, and from there the process is repeated. •Each of those rotations is called a "step", with an integer number of steps making a full rotation. •Types: •Single-coil excitation.•Full step drive.
![Page 27: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/27.jpg)
TRANSISTOR•A transistor, stands for transfer of resistance. •Transistor, a solid-state device used in electronic circuits primarily as an amplifier or switch. •They work something like a water faucet -- not only do they start and stop the flow of a current, but they also control the amount of the current. •A conventional transistor is enclosed in a protective casing and has three electrical leads.
![Page 28: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/28.jpg)
VOLTAGE REGULATOR
•A voltage regulator is a device that maintains a relatively constant output voltage even though its input voltage may be highly variable. •The voltage regulator IC maintains the output voltage at a constant value. •The 78xx is voltage regulator IC series. •The xx in 78xx indicates the fixed output voltage it is designed to provide.
![Page 29: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/29.jpg)
MICROPROCESSOR
Microcomputer –a computer with a microprocessor as its CPU. Includes memory, I/O etc. Microprocessor –silicon chip which includes ALU, register circuits & control circuits
Microcontroller –silicon chip which includes microprocessor, memory & I/O in a single package.
![Page 30: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/30.jpg)
•The word comes from the combination micro and processor. •Processor means a device that processes whatever. In this context processor means a device that processes numbers, specifically binary numbers, 0’s and 1’s. •To process means to manipulate. It is a general term that describes all manipulation. Again in this content, it means to perform certain operations on the numbers that depend on the microprocessor’s design
![Page 31: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/31.jpg)
DEFINITIONS REGARDING MICROPROCESSOR
•Microprocessor: is a programmable device that takes in numbers, performs on them arithmetic or logical operations according to the program stored in memory and then produces other numbers as a result •Instructions: Each microprocessor is designed to execute a specific group of operations. This group of operations is called an instruction set. This instruction set defines what the microprocessor can and cannot do.
![Page 32: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/32.jpg)
•Takes in: The data that the microprocessor manipulates must come from somewhere. It comes from what is called “input devices”. These are devices that bring data into the system from the outside world such as a keyboard, a mouse•Numbers: The microprocessor has a very narrow view on life. It only understands binary numbers •Words, Bytes, etc. The earliest microprocessor (the Intel 8088 and Motorola’s 6800) recognized 8-bit words. They processed information 8-bits at a time. That’s why they are called “8-bit processors”. •Later microprocessors (8086 and 68000) were designed with 16-bit words. A group of 8-bits were referred to as a “half-word” or “byte”. •Today, all processors manipulate at least 32 bits at a time microprocessors that can process 64, 80, 128 bits
![Page 33: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/33.jpg)
•Arithmetic and Logic Operations: Every microprocessor has arithmetic operations such as add and subtract as part of its instruction set. Most microprocessors will have operations such as multiply and divide. •Some of the newer ones will have complex operations such as square root. •In addition, microprocessors have logic operations as well. Such as AND, OR, XOR, shift left, shift right, etc. •Stored in memory: When a program is entered into a computer, it is stored in memory. Then as the microprocessor starts to execute the instructions, it brings the instructions from memory one at a time. •Produces: For the user to see the result of the execution of the program, the results must be presented in a human readable form
•Arithmetic and Logic Operations: Every microprocessor has arithmetic operations such as add and subtract as part of its instruction set. Most microprocessors will have operations such as multiply and divide. •Some of the newer ones will have complex operations such as square root. •In addition, microprocessors have logic operations as well. Such as AND, OR, XOR, shift left, shift right, etc. •Stored in memory: When a program is entered into a computer, it is stored in memory. Then as the microprocessor starts to execute the instructions, it brings the instructions from memory one at a time. •Produces: For the user to see the result of the execution of the program, the results must be presented in a human readable form
![Page 34: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/34.jpg)
INSIDE THE MICROPROCESSOR
Internally, the microprocessor is made up of 3 main units:
•The Arithmetic/Logic Unit (ALU) •The Control Unit. •An array of registers -for holding data while it is being manipulated.
CPU
General-Purpose Micro-processor
RAM ROM I/O Port
TimerSerial COM Port
Data Bus
Address Bus
![Page 35: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/35.jpg)
A MICROPROCESSOR-BASED SYSTEM
ORGANIZATION OF SYSTEM
![Page 36: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/36.jpg)
INTERNAL ARCHITECTURE
![Page 37: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/37.jpg)
MICROCONTROLLER
•A microcontroller is a small and low-cost computer built for the purpose of dealing with specific tasks, such as displaying information in a microwave LED or receiving information from a television’s remote control. •Microcontrollers are mainly used in products that require a degree of control to be exerted by the user. •Microcontroller is a device which integrates a number of the components of a microprocessor system onto a single microchip. So a microcontroller combines onto the same microchip : The CPU core Memory (both ROM and RAM) Some parallel digital I/O
![Page 38: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/38.jpg)
Criteria in Choosing a Microcontroller
1.Meeting the computing needs of the task efficiently and cost effectively
Speed, the amount of ROM and RAM, the number of I/O ports and timers, size, packaging, power consumption
Cost per unit
2.Availability of software development tools
3.Wide availability and reliable sources of the microcontrollers.
![Page 39: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/39.jpg)
Introduction to Microcontroller The microcontroller is a very common component in modern electronic systems. Its use is so widespread that it is almost impossible to work in electronics without coming across it. Microcontroller are used in a wide number of electronic systems such as:
Engine management systems in automobiles. Keyboard of a PC. Electronic measurement instruments (such as digital multimeters, frequency synthesisers, and oscilloscopes) Printers,Mobile phones. Televisions, radios, CD players, tape recording equipment.
![Page 40: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/40.jpg)
Comparison of 8051 Family MembersFeatures 8051 8052 8031ROM 4K 8K 10KRAM 128 256 128Timers 2 3 2I/O pins 32 32 32Serial port 1 1 1 Interrupt Sources 6 8 6
![Page 41: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/41.jpg)
Features of 8051
ROM - 4K bytesRAM - 128 bytesTimer - 2I/O pins - 32Serial port - 1Interrupt sources - 6
8051 is based on CISC architecture. It is based on Harvard architecture. So, it has separate
program and data memory.
![Page 42: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/42.jpg)
APPLICATIONS OF MICROCONTROLLERS
•Mobile Phones •Auto Mobiles •Washing Machines •Cameras •Security Alarms
![Page 43: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/43.jpg)
Microprocessor vs Micro-controllers
MicroprocessorsHigh end of market where performance mattersHigh power dissipation–high costNeed peripheral devices to work Diff programs multiple times
MicrocontrollersTargeted for low end of market where performance does not matterLow power dissipation –low cost Memory plus I/O devices, all integrated into one chipSingle program multiple times
![Page 44: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/44.jpg)
TYPES OF MICRO CONTROLLERS
![Page 45: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/45.jpg)
•In 8-bit microcontroller, the point when the internal bus is 8-bit . The examples of 8-bit microcontrollers are Intel 8031/8051, PIC1x and Motorola MC68HC11 families. •The 16-bit microcontroller performs greater precision and performance as compared to 8-bit. Some examples of 16-bit microcontroller are 16-bit MCUs are extended 8051XA, PIC2x, Intel 8096 and Motorola MC68HC12 families. •The 32-bit microcontroller uses the 32-bit instructions to perform the arithmetic and logic operations. These are used in automatically controlled devices including engine control systems, office machines, appliances . Some examples are Intel/Atmel 251 family, PIC3x.
BITS
![Page 46: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/46.jpg)
•Embedded memory microcontroller: When an embedded system has a microcontroller unit that has all the functional blocks available on a chip is called an embedded microcontroller. For example, 8051 having program & data memory, I/O ports, serial communication, counters and timers and interrupts on the chip is an embedded microcontroller. •External Memory Microcontroller: When an embedded system has a microcontroller unit that has not all the functional blocks available on a chip is called an external memory microcontroller. For example, 8031 has no program memory on the chip is an external memory microcontroller.
MEMORY DEVICES
![Page 47: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/47.jpg)
INSTRUCTION SET
•CISC: CISC is a Complex Instruction Set Computer. It allows the programmer to use one instruction in place of many simpler instructions.
•RISC: The industry trend for microprocessor design is for Reduced Instruction Set Computers (RISC) designs. It allows each instruction to operate on any register or use any addressing mode and simultaneous access of program and data.
![Page 48: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/48.jpg)
MEMORY ARCHITECTURE
•Harvard Memory Architecture Microcontroller: The point when a microcontroller unit has a dissimilar memory address space for the program and data memory, the microcontroller has Harvard memory architecture in the processor. •Princeton Memory Architecture Microcontroller: The point when a microcontroller has a common memory address for the program memory and data memory, the microcontroller has Princeton memory architecture in the processor.
![Page 49: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/49.jpg)
Embedded Systems
Embedded system means the processor is embedded into that application.
An embedded product uses a microprocessor or microcontroller to do one task only.
In an embedded system, there is only one application software that is typically burned into ROM.
Example printer, keyboard, video game player
![Page 50: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/50.jpg)
Block Diagram of 8051
CPU
On-chip RAM
On-chip ROM for program code
4 I/O Ports
Timer 0
Serial PortOSC
Interrupt Control
External interrupts
Timer 1
Timer/Counter
Bus Control
TxD RxDP0 P1 P2 P3
Address/Data
Counter Inputs
![Page 51: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/51.jpg)
C2
30pF
C1
30pF
XTAL2
XTAL1
GND
The 8051 has an on-chip oscillator but requires an external clock to run it.A quartz crystal oscillator is connected to inputs XTAL1 and XTAL2.It also needs 2 capacitors of 30pF value.One side of each capacitor is connected to the ground as shown below:
![Page 52: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/52.jpg)
FEATURES OF 8051
1. 4 KB on chip program memory.2. 128 bytes on chip data memory(RAM).3. 4 register banks.4. 128 user defined software flags. 5. 8-bit data bus 6. 16-bit address bus 7. 32 general purpose registers each of 8 bits8. 16 bit timers (usually 2, but may have more, or less).9. 3 internal and 2 external interrupts.10. Bit as well as byte addressable RAM area of 16 bytes.11. Four 8-bit ports, (short models have two 8-bit ports). 12. 16-bit program counter and data pointer. 13. 1 Microsecond instruction cycle with 12 MHz Crystal
![Page 53: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/53.jpg)
Registers in 8051In CPU, registers are used to store information
temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. 8051 have 8-bit registers
D7 D6 D0D1D2D3D4D5
MSB LSB
The most widely used registers are A (accumulator), B, R0-R7, PC (Program Counter).
![Page 54: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/54.jpg)
Program Counter (PC)PC points to the address of the next instruction to be executed. As the CPU fetches the opcode from the program ROM, the PC is incremented to point to the point to the next instruction. This means that the 8051 can access program address 0000-FFFFH, a total of 64Kbytes of code. It is also called instruction pointer
Flag Bit8051 has a flag register to indicate arithmetic conditions such as carry bit. The flag register of 8051 is called Program Status Word (PSW) register.
![Page 55: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/55.jpg)
PSW (Program Status Word) Register
CY PSW.7 Carry FlagAC PSW.6 Auxiliary Carry FlagF0 PSW.5 Available to the user for general purposeRS1 PSW.4 Register Bank selector bit 1RS0 PSW.3 Register bank selector bit 0OV PSW.2 Overflow flag--- PSW.1 User-definable bitP PSW.0 Parity flag.(odd/even no of 1 bit in the accumulator)
RS1 RS0 Register bank Address 0 0 0 00H-07H 0 1 1 08H-0FH 1 0 0 10H-17H 1 1 1 18H-1FH
![Page 56: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/56.jpg)
Its an 8 bit register.Although it is an 8 bit register, only 6 bits of it are used. The two unused bits are user definable flags.Four bits are called conditional flags, they indicate some conditions that result after an instruction is executed. These 4 are CY (carry), AC (Auxiliary Carry), P (Parity) and OV (Over Flow).
![Page 57: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/57.jpg)
CY flag:- This flag is set when there is a carry out from the D7 bit. This flag bit is affected after an 8-bit addition or subtraction.
AC flag :- If there is a carry from D3 to D4 during ADD or SUB operation, this bit is set; otherwise cleared.
P flag :- It reflects the number of 1’s in the A (accumulator) register only. If A register contains an odd number of 1’s, then P=1.If its even, then P=0.
OV Flag :- This is set whenever the result of a signed number operation is too large, causing the high order bit to overflow into sign bit.
![Page 58: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/58.jpg)
Example:
1)38h+2Fh=67
0001 1100+0010 1111 0110 0111
CY=0no carry beyond D7.
AC=1carry from D3 to D4.
P=1 since accumulator has an odd number of 1’s.
![Page 59: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/59.jpg)
Stack in 8051It is a section of RAM.Stack is used to store information temporarily.The information could be data or address.
How stack is accessed?The register used to access the stack is called Stack Pointer (SP).SP is 8 bits wide. It can take values 00-FFh.Storing of a CPU register in stack is called PUSH and pulling the contents is called POP.
![Page 60: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/60.jpg)
Pin description of 8051
![Page 61: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/61.jpg)
•Pins 1-8: Port 1 Each of these pins can be configured as an input or an output. •Pin 9: RS A logic one on this pin disables the microcontroller and clears the contents of most registers. In other words, the positive voltage on this pin resets the microcontroller. By applying logic zero to this pin, the program starts execution from the beginning. •Pins10-17: Port 3 Similar to port 1, each of these pins can serve as general input or output. Besides, all of them have alternative functions: •Pin 10: RXD Serial asynchronous communication input or Serial synchronous communication output. •Pin 11: TXD Serial asynchronous communication output or Serial synchronous communication clock output. •Pin 12: INT0 Interrupt 0 input. •Pin 13: INT1 Interrupt 1 input. •Pin 14: T0 Counter 0 clock input. •Pin 15: T1 Counter 1 clock input. •Pin 16: WR Write to external (additional) RAM. •Pin 17: RD Read from external RAM. •Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which specifies operating frequency is usually connected to these pins. Instead of it, miniature ceramics resonators can also be used for frequency stability. Later versions of microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.
PIN DESCRIPTION
![Page 62: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/62.jpg)
•Pin 20: GND Ground. •Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are configured as general inputs/outputs. In case external memory is used, the higher address byte, i.e. addresses A8-A15 will appear on this port. Even though memory with capacity of 64Kb is not used, which means that not all eight port bits are used for its addressing, the rest of them are not available as inputs/outputs. •Pin 29: PSEN If external ROM is used for storing program then a logic zero (0) appears on it every time the microcontroller reads a byte from memory •Pin 30: ALE Prior to reading from external memory, the microcontroller puts the lower address byte (A0-A7) on P0 and activates the ALE output. After receiving signal from the ALE pin, the external register memorizes the state of P0 and uses it as a memory chip address. Immediately after that, the ALU pin is returned its previous logic state and P0 is now used as a Data Bus. As seen, port data multiplexing is performed by means of only one additional (and cheap) integrated circuit. In other words, this port is used for both data and address transmission. •Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address transmission with no regard to whether there is internal memory or not. It means that even there is a program written to the microcontroller, it will not be executed. Instead, the program written to external ROM will be executed. By applying logic one to the EA pin, the microcontroller will use both memories, first internal then external (if exists). •Pin 32-39: Port 0 Similar to P2, if external memory is not used, these pins can be used as general inputs/outputs. Otherwise, P0 is configured as address output (A0-A7) when the ALE pin is driven high (1) or as data output (Data Bus) when the ALE pin is driven low (0). •Pin 40: VCC +5V power supply.
![Page 63: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/63.jpg)
Reasons for writing programs in C instead of Assembly
It is easier and less time consuming to write in C than Assembly.
C is easier to modify and update.
You can use available in-function libraries.
C code is portable to other microcontrollers with little or no modification.
![Page 64: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/64.jpg)
Program No:- 1Aim:- Write a program to add two numbers.#include<stdio.h>#include<conio.h>void main(){int a,b,c;printf("Enter the two numbers=");scanf("%d%d",&a,&b);c=a+b;printf("Sum=%d",c);getch();}Output:-
![Page 65: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/65.jpg)
Program No:- 2Aim:- Write a program to check whether the number is greater or not.#include<stdio.h>#include<conio.h>void main(){int a,b;printf("Enter the two numbers=");scanf("%d%d",&a,&b);if(a>b)printf("a is greater");elseif (b>a)printf("b is greater");elseprintf("both the numbers are same");getch();}Output:-
![Page 66: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/66.jpg)
Program No:- 3Aim:- Write a program to swap the numbers with using 3rd variable.#include<stdio.h>#include<conio.h>void main(){clrscr();int a,b,c;printf("Enter the value of a,b");scanf("%d%d",&a,&b);c=a;a=b;b=c;printf("%d,%d",a,b);getch();}Output:-
![Page 67: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/67.jpg)
Program No:- 4Aim:- Write a program to swap the numbers without using 3rd variable.#include<stdio.h>#include<conio.h>void main(){clrscr();int a,b;printf("Enter the two numbers=");scanf("%d%d",&a,&b);a=a+b;b=a-b;a=a-b;printf("%d,%d",a,b);getch();}Output:-
![Page 68: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/68.jpg)
Program No:- 5Aim:- Write a program for doing simple calculations.#include<stdio.h>#include<conio.h>void main(){clrscr();int a,b,s,d,m,di;printf("Enter the two numbers=");scanf("%d%d",&a,&b);s=a+b;d=a-b;m=a*b;di=a/b;printf("Sum= %d, Difference =%d, Multiplication =%d, Division =%d",s,d,m,di);getch();}Output:-
![Page 69: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/69.jpg)
Program No:- 6Aim:- Write a program to check the number is greater in 3 numbers.#include<stdio.h>#include<conio.h>void main(){int a,b,c;clrscr();printf("Enter the value of a,b,c=");scanf("%d%d%d",&a,&b,&c);if (a>b&&a>c)printf("a is greater");else if(b>c&&b>a)printf("b is greater");else if (c>a&&c>b)printf("c is greater");elseprintf("a=b=c");getch();}Output:-
![Page 70: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/70.jpg)
Program No:- 7Aim:- Write a program to separate the 2 numbers of 2 digit number.#include<stdio.h>#include<conio.h>void main(){int a,b;clrscr();printf("enter the value of a=");scanf("%d",&a);b=a%10;printf("%d",b);a=a/10;printf("\n%d",a);getch();}Output:-
![Page 71: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/71.jpg)
Program No:- 8Aim:- Write a program to reverse a number.#include<stdio.h>#include<conio.h>void main(){int a,i,s=0;clrscr();printf("enter the number=");scanf("%d",&a);while(a>0){i=a%10;s=s*10+i;a=a/10;}printf("%d",s);getch();}Output:-
![Page 72: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/72.jpg)
Program No:- 9Aim:- Write a program to which tells about the input age is of adult or minar.#include<stdio.h>#include<conio.h>void main(){int age;clrscr();printf("enter the age");scanf("%d",&age);if(age>18)printf("the person is adult");elseprintf("the person is minor");getch();}Output:-
![Page 73: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/73.jpg)
Program No:- 10Aim:- Write a program to print the numbers from 0 to 99 using the loops.#include<stdio.h>#include<conio.h>void main(){int i;clrscr();for(i=0;i<=99;i++){printf("%d",i);}getch();}Output:-
![Page 74: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/74.jpg)
Program No:- 11Aim:- Write a program to check whether the number is palindrome or not.#include<stdio.h>#include<conio.h>void main(){int a,b,c,p,q;clrscr();printf("enter the number=");scanf("%d",&a);{p=a%100;q=a/100;b=p%10;c=p/10;p=b*10+c;}if(p==q)printf("palindrome number");elseprintf("not");getch();}Output:-
![Page 75: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/75.jpg)
Program No:- 12Aim:- Write a program to print the numbers from 100 to 1 using for loop.#include<stdio.h>#include<conio.h>void main(){int i;for(i=100;i>=1;i--){printf("%d",i);}getch();}Output:-
![Page 76: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/76.jpg)
C data types for 8051Unsigned char
8-bit datatype.value range from 0-255(00-FFh).
Signed char
8-bit datatype.D7 of D7-D0 represent sign(-ve or +ve).We have 7 bits for value of signed number. Range from -128 to 127. Default is signed value.
![Page 77: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/77.jpg)
Unsigned int
16bit datatype.value in a range of 0-65535.used to define 16-bit memory address.8051 is 8-bit microcontroller, so int datatype take 2bytes of RAM.
Signed int
16 bit datatype.Uses MSB (D15 of D15-D0) to represent sign(-ve or +ve).15 bit for magnitude.Value range from -32768 to 32767.
![Page 78: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/78.jpg)
Time DelayThere are two ways to create a time delay 8051:
1.Using a simple loop 2.Using the 8051 timers
8051 Timers
Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as 2 separate registers of low byte and high byte.
![Page 79: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/79.jpg)
Timer 0 Register
The 16-bit registers of Timer 0 are accessed as low byte and high byte. The low byte is called TL0 (Timer 0 low byte) and the high byte register is called TH0 (Timer 0 high byte). These registers can be accessed like any other register, such as A,B,R0,R1, etc.
D15 D14 D13 D12 D11 D10 D9 D0D1D2D3D4D5D6D7D8
TH0 TL0
![Page 80: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/80.jpg)
Timer 1 register
Timer 1 is also 16 bit register, and its 16-bit register is split into two bytes, referred to as TL1(Timer 1 low byte) and TH1 (Timer 1 high byte). These registers are accessible in the same way as Timer 0.
D14 D13 D12 D11 D10 D9 D8 D7 D6 D5D15 D1D2D3D4 D0
TH1 TH0
![Page 81: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/81.jpg)
Types of data transferTwo ways of transferring data:ParallelSerial
In parallel data transfer, often 8 or more lines (wire conductors) are used to transfer data to a that is only a few feet away.
Ex: printers, hard disk
Each uses cables with many wire strips. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel, the distance cannot be great.
![Page 82: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/82.jpg)
To transfer to a device located many meters away, the serial method can be used.In serial communication, the data is send one bit at a time.
Basics of Serial CommunicationIf data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio tones, which are sinusoidal shaped signal. This conversion is performed by a peripheral device called as MODEM=modulator/demodulator.Serial data communications uses two methods 1.Synchronous method transfers a block of data (character) at a time.
2.Asynchronous method transfers a single byte at a time.
![Page 83: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/83.jpg)
Half and Full duplex transmissionIn data transmission if the data can be transmitted and received, it is a duplex transmission.
Transmitter Receiver
SenderReceiver
TransmitterReceiver
Transmitter
ReceiverTransmitter
Transmitter
ReceiverSender
Receiver
Receiver
Serial Transfer Parallel TransferD0
D7
Simplex
Half Duplex
Full Duplex
![Page 84: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/84.jpg)
Asynchronous serial communication and data framing
Start and Stop bitsAsynchronous serial communication is widely used for character-oriented transmission, while block-oriented data transfer uses synchronous method.In asynchronous method, each character is placed between start and stop bits. This is called framing.Start bit is always one bit and it is a low bitStop bit can be one or two bits and it is a high bit
stopbitspace
Goes out last
0 0 0 1 0 1 0 1 start bit
D7 D0 Goes out first
![Page 85: modidied.ppt](https://reader037.fdocuments.in/reader037/viewer/2022110323/55cf902d550346703ba38d22/html5/thumbnails/85.jpg)