You are on page 1of 12

Embedded Systems

A system is a way of working, organizing or doing one or many tasks according to a fixed plan, program, or set of rules. e.g. 1. Time display system 2. Automatic clothes washing system

Embedded System:
The embedded system is a combination of computer hardware, software additional electrical & mechanical parts.. It is a dedicated computer based system for an application or product. As its s/w usually embeds in ROM, it does not need secondary memories as in commuter. As embedded system has s/w assigned to keep in view three constraints 1. Available system memory 2. Available processor speed 3.the need to limit power dissipation when running the system continuously in cycles in cycles of wait for events ,run, stop, wake-up. These are Real-time systems process events. These events occur on external inputs cause other events to occur as outputs. Minimizing response time is usually a primary objective, or otherwise the entire system may fail to operate properly Therefore embedded systems employ the use of a RTOS (Real-Time Operating System) It is Operating Systems with the necessary features to support a Real-Time System Real-Time System A system where correctness depends not only on the correctness of the logical result of the computation, but also on the result delivery time. It responds in a timely, predictable way to unpredictable external stimuli arrivals.
Semiconductor Technologies VEDANT, Lucknow 1

The real Time Systems can be further divided into two types: Soft Real-Time System Compute output response as fast as possible, but no specific deadlines that must be met. Hard Real-Time System Output response must be computed by specified deadline or system fails. CHALLENGES FOR EMBEDDED SYSTEMS: 1. limited operating system support for programming 2. limited secondary memory 3. limited Random Access memory 4. limited processing power 5. Interaction with hardware 6. Absence of standard input/output devices

The process of translating the code that is written by humans to the code that is understandable by the microprocessor. Steps involved in transforming the source code to the final executable format are listed below: 1. Preprocessing 2. Compiling 3. Linking 4. Locating Some common characteristics Single-functioned Executes a single program, repeatedly Tightly-constrained Low cost, low power, small, fast, etc. Reactive and real-time Continually reacts to changes in the systems environment BuiThes e are Real-

Semiconductor Technologies VEDANT, Lucknow

Must compute certain results in real-time without delay Design Challenges (optimizing design metrics): Common metrics Unit cost: the monetary cost of manufacturing each copy of the system, excluding NRE cost NRE cost (Non-Recurring Engineering cost): The one-time monetary cost of designing the system Size: the physical space required by the system Performance: the execution time or throughput of the system Power: the amount of power consumed by the system Flexibility: the ability to change the functionality of the system without incurring heavy NRE cost Time-to-prototype: the time needed to build a working version of the system Time-to-market: the time required to develop a system to the point that it can be released and sold to customers Maintainability: the ability to modify the system after its initial release Correctness, safety, many more He performance design metric: Widely-used measure of system, widely-abused Clock frequency, instructions per second not good measures Latency (response time) Time between task start and end Throughput Tasks per second, e.g. Camera A processes 4 images per second Speedup of B over S = Bs performance / As performance Throughput speedup = 8/4 = 2

A microcontroller is a computer-on-a-chip, or, a single-chip computer. Micro Suggests that the device is small, and controller tells that the device might be used to control objects, processes, or events. Another term to describe a microcontroller is embedded controller, because the microcontroller and

Semiconductor Technologies VEDANT, Lucknow

its support circuits are often built into, or embedded in, the devices they control. We can find microcontrollers in all kinds of things these days. Any device that measures, stores, controls, calculates, or displays information is a candidate for putting a microcontroller inside. The largest single use for microcontrollers is in automobilesjust about every car manufactured today includes at least one microcontroller for engine control, and often more to control additional systems in the car. In desktop computers, you can find microcontrollers inside keyboards, modems, printers, and other peripherals Why do we need to learn Microprocessors/controllers? The microprocessor is the core of computer systems. Nowadays many communications, digital entertainment, portable devices, are controlled by them. A designer should know what types of components he needs, ways to reduce production costs and product reliable. Different aspects of a microprocessor/controller Hardware :Interface to the real world Software :order how to deal with inputs The necessary tools for a microprocessor/controller CPU: Central Processing Unit I/O: Input /Output Bus: Address bus & Data bus Memory: RAM & ROM Timer Interrupt Serial Port Parallel Port

Semiconductor Technologies VEDANT, Lucknow

Microprocessor vs. Microcontroller Microprocessor CPU is stand-alone, RAM, ROM, I/O, timer are separate Designer can decide on the amount of ROM, RAM and I/O ports. expansive versatility general-purpose Microcontroller CPU, RAM, ROM, I/O and timer are all on a single chip fix amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical single-purpose Embedded system 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 Three 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 easy to upgrade cost per unit 2. availability of software development tools assemblers, debuggers, C compilers, emulator, simulator, technical support 3. wide availability and reliable sources of the microcontrollers
Semiconductor Technologies VEDANT, Lucknow 5

Semiconductor Technologies VEDANT, Lucknow

Features of 8051 8 bit CPU optimized for control applications Harvard Architecture Extensive Boolean processing capabilities 4K B on chip program memory 128 bytes on chip data Ram 32 bit bi directional I/O Two sixteen bit timer counters Full duplex UART Powerful Interrupt structure

Register Banks Four banks of 8 byte-sized registers, R0 to R7 Addresses are : 18 - 1F for bank 3 10 - 17 for bank 2 08 - 0F for bank 1 00 - 07 for bank 0 (default) Active bank selected by bits [ RS1, RS0 ] in PSW. Permits fast context switching in interrupt service routines (ISR). Instruction Set Data transfer Arithmetic Mul/Div Logic Byte, bit manipulations Control Transfer : Unconditional

Semiconductor Technologies VEDANT, Lucknow

ACALL , LCALL, JMP, JMP @A+DPTR Conditional JZ,JNZ,JB,JNB,JBC CJNE,DJNZ, RET 8051 Addressing Modes



Immediate: operand is constant contained in instruction A,#31 Register: operand is register A,R0 Direct: operand is memory cell whose address is contained in instruction MOV 30H,#11 ; Mem[30H] = 11

Register indirect: operand is memory cell whose address is contained in register Restrictions: only 8-bit registers R0 and R1, and 16-bit register DPTR may be used INC @R1 MOVX @DPTR,A ; Mem[DPTR] = A

Indexed: operand is memory cell whose address is the sum of two registers Restrictions: only applies to MOVC (move constant/move from code mem.) and JMP instructions: MOVC A,@A+DPTR MOVC A,@A+PC JMP @A+DPTR

Indexed: Example 2, implementing case/switch statement using jump table: MOV DPTR,#TABLE ; DPTR=address of TABLE (CM) MOV A,#INDEX ; A = index
Semiconductor Technologies VEDANT, Lucknow 8


RL A ; A *= 2 JMP @A+DPTR ; the jump itself ... AJMP CASE0 AJMPCASE1 AJMPCASE2

8051 Arithmetic Instructions Instruction increment decrement add add with carry with borrow multiply divide %B decimal adjust A(dec) 8051 Logical Instructions Instruction bitwise AND bitwise OR bitwise XOR clear complement rotate left rot left w carry Mnemonic Meaning ANL A,reg|dir|indir|immA=A&oper ANL dir,A|imm dir=dir&opr ORL A,reg|dir|indir|immA=A|oper ORL dir,A|imm dir=dir|opr XRL A,reg|dir|indir|immA=A^oper XRL dir,A|imm dir=dir^opr CRL A A=0 CPL A A=~A RL A RLC A

Mnemonic Meaning INC A|reg|dir|indir|DPTR oper++ DEC A|reg|dir|indir oper-ADD A,reg|dir|indir|immA=A+oper ADDC A,reg|dir|indir|immA=A+oper+Csub. SUBB A,reg|dir|indir|immA=A-oper-C MUL AB B,A = A*B DIV AB A = A/B B=A DA A A(hex) =

Semiconductor Technologies VEDANT, Lucknow

rotate right rot right w carry swap A[4:7]

RR A RRC A SWAP A[0:3]<-> A

8051 Copy and Transfer Instructions Instruction move Mnemonic MOV MOV MOV MOV MOV Meaning A,reg|dir|indir|imm A = oper reg,A|dir|imm reg = oper dir,A|reg|dir|indir|imm dir = oper indir,A|dir|imm indir = oper DPTR,imm16 DPTR oper on oper of A <-> oper A[0:3] <-> oper[0:3] oper oper A=

= imm16 push stack pop stack exchange

PUSH dir POP dir XCH A,reg|dir|indir XCHD A,indir

move extern MOVX A,@reg|@DPTR A = oper MOVX @reg,A =A MOVX @DPTR,A =A mv code mem MOVC A,@A+DPTR|@A+PC oper 8051 Boolean Instructions Instruction and oper or Mnemonic ANL C,bit|/bit ORL C,bit|/bit

Meaning C=C& C = C | oper


Semiconductor Technologies VEDANT, Lucknow

move bit clear bit set bit complement Bit manipulation

MOV C,bit MOV bit,C CLR C CLR bit SETB C SETB bit CPL C CPL bit

C = bit bit = C C=0 bit = 0 C=1 bit = 1 C = !C bit = !bit

Bit addressing can only be applied to internal RAM addresses 20H2FH and SFR addresses that end at 0 or 8 Carry flag works as Accumulator 8051 Jump Instructions Instruction jump unc. PC[15:11]#addr11 call unc. PC[15:11]#addr11 LCALL addr16 addr16 return no operation NOP jump cond. !C bit !bit bit, JB bit,reladdr JNB bit,reladdr JBC bit,reladdr PC = PC +/- 127 if PC = PC +/- 127 if PC = PC +/- 127 if bit = 0
Semiconductor Technologies VEDANT, Lucknow 11

Mnemonic SJMP reladdr AJMP addr11

Meaning PC = PC +/- 127 PC =

LJMP addr16 PC = addr16 JMP @A+DPTR PC = A+DPTR ACALL addr11 push PC PC = push PC, PC =


pop PC, goto PC (from subroutine) RETI (from interrupt) PC = PC+1 JC reladdr PC = PC +/- 127 if C JNC reladdr PC = PC +/- 127 if

A==0 A!=0 decr+jmp comp+jmp


reladdr reladdr reg|dir,reladdr

PC = PC +/- 127 if PC = PC +/- 127 if

reg-- | dir--, PC = PC +/- 127 if reg|dir!=0 CJNE A,dir|imm,reladdr PC = PC +/- 127 if A!=opr CJNE reg,imm,reladdr PC = PC +/- 127 if reg!=imm CJNE indir,imm,reladdr PC = PC +/- 127 if indir!=imm

8051 stack grows from low addresses to high addresses SFR SP (address 81H) points to top of stack, i.e., if you push a value onto the stack, it will be stored at address SP+1 Be careful: SP is initialized to 07H, alternate register banks 1, 2, and user bit vars occupy internal RAM addresses 08H-2FH Special instructions: PUSH op POP op op must be specified using direct addressing! General-purpose processors Programmable device used in a variety of applications Also known as microprocessor Features Program memory General datapath with large register file and general ALU User benefits Low time-to-market and NRE costs High flexibility Pentium the most well-known, but there are hundreds of others
Semiconductor Technologies VEDANT, Lucknow 12