You are on page 1of 14




WHAT IS EMBEDDED PROCESSOR Embedded System: - Any device, or collection of devices, that contain one or more dedicated computers, microprocessors, or microcontrollers - Device(s) may be local - Printer, automobile, etc. - Devices may be distributed - Aircraft, ship, internet appliance - A PC or workstation may be an embedded system • Key point: - Embedded computing devices have rigidly defined operational bounds. Not general purpose computers ( PC, Unix workstation )

WHY ARE EMBEDDED SYSTEMS DIFFERENT • Dedicated to a specific task or tasks • Rich variety of microprocessors ( over 300 types ) • Designs are cost-sensitive • Have real-time performance constraints • Used with Real-Time Operating Systems (RTOS) • Software failure can be life-threatening • May have constraints on power consumption • Operate over a wide-range of environmental conditions • Fewer system resources then a desktop system • All code might be stored in ROM • Require specialized design tools • May have on-chip debugging resources

CHARACTERISTICS OF EMBEDDED SYSTEM • In general, there is no architectural link to standard platforms - PC ( Win9X, NT ), MAC, HP, Sun are considered the standard platforms - Almost every design ( hardware and software ) is unique - The hardware and software are highly integrated and interdependent - ASICS, microcontrollers • Typically, have moderate to severe real time constraints - Real time means system must be able to respond to the outside world • May or may not have Operating System ( O/S ) services available - No printf() for debugging when there is no terminal • Tolerance for bugs is 1000X ( or more ) lower in embedded systems then in desktop computers.


- May be life-threatening consequences if system fails - Often engineered for the highest possible performance at the lowest cost TYPES OF EMBEDDED PROCESSOR   Microcontroller – A small and self sufficient computer in a chip, used to control devices. RISC processor – Reduced Instruction Set Computer is a single chip microprocessor developed by IBM Digital signal processor – Involves with signals by the sequence of numbers or symbols and the processing these signal. It usually measures, filter and compress analogue signals

DIFFERENT OF MICROPROCESSOR AND MICROCONTROLLER Microprocessor - It is a CPU - An integrated circuit which forms the central processing unit for computer or embedded controller, but requires additional support circuitry to function - MC68000, Pentium, Athlon, etc.



Microcontroller - It is a single chip - A microprocessor plus additional peripheral support devices integrated into a single package - Peripheral support devices may include: • Serial ports ( COM ), Parallel ( Ports ), Ethernet ports, A/D & D/A • Interval timers, watchdog timers, event counter/timers, real time clock ( RTC ) • Other local processors ( DSP, numeric coprocessor, peripheral controller ) - 8051 (more specifically ADuC812 ) is a microcontroller.

FUNCTIONAL DESCRIPTION OF MICROCONTROLLER Most parts of digital computers, including digital peripherals, are made up of simple logic elements called gates. In a CPU those gates may form the Program Counter to fetch the next instruction, the instruction decoder, the Arithmetic Logic Unit, Stack Pointer, Status register etc. • • • • The CPU processes the program. More precisely it executes the instructions from the program memory pointed to by the program counter. It needs a clock to move from one step in a sequence to the next one. The ROM holds the program and constant data. This information is persistent and remains with no power applied. The RAM memory is used to hold intermediate results and other temporary data during program execution. Special Function Registers are hardwired registers controlling the CPU, I/O ports or other peripherals. Exempli gratia: A write to an I/O port register could change the voltage level on its output pins. Reading from it might reflect the voltage on its input pins.



OCCURANCE Microcontrollers are widely used in: • • • • • • • entertainment electronics modern appliances modern vehicles personal computers and peripherals infrastructures of buildings security systems etc

Important features of microcontrollers are: • • • • small size low power consumption low prize simplicity of use in embedded systems

Typical input devices of microcontrollers are: • • • • • switches keypads temperature sensors pressure sensors etc

Typical output devices are: • • • LEDs, (LCD) displays beepers drivers for all kinds of loads (relays, motors etc.)

Internally microcontrollers can only process digital signals, logic 0s or logic 1s. Translation circuits are required for all other signals the microcontroller can't process directly. Examples are Analog to Digital or Digital to Analog converters but also level shifters from other digital sources not compatible with the microcontroller. Sometime these are directly built into the integrated circuit of a microcontroller.



PERIPHERALS Popular peripherals found in and around microcontrollers are: • • • • • • •

• • •

General purpose & parallel I/O ports. Capture, Compare, Pulse Width Modulation (PWM) Analog to Digital Converters (ADC or A/D) Digital to Analog Converters (DAC or D/A) Serial Peripheral Interfaces (SPI) Timers & Counters Dividers I2C = Inter-Integrated Circuit two wire communication interfaces. RS232 (UART), IrDA (infrared port), USB Controller Area Network Bus (CAN) Local Interconnect Network (LIN)


A word is fundamental unit of storage in a computer. It is a group of bits that a computer's central processing unit treats as a single working unit. It is normally the width of the program or data memory bus (or internal CPU registers if different). The 16F84 microcontroller has a program bus width of 14 bits for instructions, hence the instruction word sizes are 14 bits. Word sizes are different for different computers. However it is important to know them, at least the data word size, as data types of high level languages may rely on it. Therefore an integer might be 16 bits on a computer with a word size of 16 bits but 32 bits on a 32-bit system. Note that on a 8bit system integers have usually a size of 16 bits.


PROGRAM MEMORY Most microcontrollers contain non-volatile memory on chip to hold the program or constant data. C examples of code stored in non-volatile memory: const int i = 1; //constant declarations "Hello World"; //literals while(1) continue; //program code Microcontrollers are manufactured with one of the following memory types or combinations of it. ROM - Read Only Memory:
• •

Factory (Mask) Programmed Memory, not field programmable. Simplest non-volatile Memory Technology.

Good for large volumes of identical microcontrollers. PROM - Programmable Rom, OTP One-Time Programmable:
• • •

Field programmable. Can't be erased. Cheap.

EPROM - Erasable Programmable ROM:
• •

Field programmable. Can be UV-erased if in a windowed package.

EEPROM - Electrically Erasable PROM:
• • •

Field programmable. Can be reprogrammed, byte erasable. Slower reads than EPROMs.

• •

Similar to EEPROM technology. Erased in units of blocks.



This type of memory has become very popular in recent years and almost all new microcontrollers are designed with it. DATA MEMORY Volatile general purpose memory is used for temporarily storage of data during program execution. A C example to allocate storage space in volatile memory:
int i;

SRAM - Static Random Access Memory: • • Volatile memory (data is lost with power loss). Used as temporary storage on chip; fast reads and writes.

Many modern microcontrollers have a small amount of additional Electrically Erasable PROM for non-volatile data storage on chip. Writes to these memories are slow. Reads & writes require special instructions and programming procedures. I/O DRIVERS Microcontrollers come in small packages with limited I/O pins. To provide greater flexibility most microcontrollers support more than one function on a single pin i.e. a single pin could support a general purpose output, a general purpose input and an analog input. Typically only one function at a time can be activivated through the programming of a special function register. Ports that can be used as in- and outputs are bidirectional.

Output pins typically are implemented as tri-state logic circuitries, supporting low, high and high impedance.

Inputs generally are high impedance or configured as input on the high impedance state of a bidirectional port (a group of pins).



SPECIAL FUNCTION REGISTERS 1/2 Special Function Registers control the various functions of a microcontroller. They can be divided in two categories: 1. Those Control Registers, required and wired into the CPU and not necessarily part of the addressable memory, for program flow and arithmetic functions like: • • • • • CPU working registers Status register Stack Pointer Program Counter etc.

Compilers of high level languages take care of those registers. Programmers of high level languages (C, Pascal, etc.) do not need to worry about them. 2. Those required by peripherals. Writing to these registers could set a timer, toggle an output pin, enable a serial communication etc. Set by the hardware they may contain the timer value, the input potential of a pin (high or low), a received byte from a serial communication etc




The picture shows a typical but simplified symbolic implementation of a bidirectional 8-bit wide tri-state port with one pin drawn. Three registers are required in our example circuit: • • The DIR (direction) register to enable or disable the output driver. The GPIO [out] latches to set the output pins high or low when enabled via DIR and the GPIO [in] latches to read the potentials on the pins.

Although the GPIO has two different input and output latches they are mapped in hardware to the same I/O address and therefore appear as one register. Configuring the port as an input will disable the output driver and therefore enable the high impedance state on the pins. A write to the port will only change the GPIO output register values but not the pins itself. Enabling the output by writing to the direction register will drive the pins potential to the value stored in the appropriate bit in the GPIO [out] register. Reading back a value in this configuration will read the real potential on the pin and not the stored GPIO [out] value. Therefore the value read back from a pin, for example in case of a short circuit, might be different from the value set in the GPIO [out]. Its characteristic could be used to detect system failures.


Microcontrollers with Read-Modify-Write cycles for write operations execute those in the subsequent fashion: • • • Read the register content (in our case the true pin potential GPIO [in]) Modify the register values Write them back to the register GPIO [out]

Combined with above port implementation this may lead to unexpected side effects. Imaging two immediate writes to the GPIO [out]: A bit set instruction to set bit-0 and another bit set instruction to set bit-1 If for any reason the potential of pin 0 was kept low while executing the second write instruction, then bit 0 would have been cleared again because GPIO [in] would have read as a low. Apart from a short circuit also a capacitive load might lead to the same effect as the pin's potential may not change fast enough to be read as a high on the second instruction. The time between the two writes, depending on clock and microcontroller, might only be a few hundred nanoseconds. Port implementations like that can be found in popular microcontrollers. More sophisticated port implementations do exist i.e. providing the option to read GPIO [out] avoiding those problems.

SEPARATE I/O SPACE AND MEMORY-MAPPED I/O There are two fundamental architectures for mapping Special Function Registers into the memory space. 1. I/O space and memory space are separated. Access to the I/O control registers requires special I/O instructions.



2. The memory-mapped I/O maps the I/O control registers into the CPU's memory address space. Reads and writes to the control registers are done via absolute memory addresses; variables at absolute addresses or pointers to absolute addresses in high level languages. No special instructions are required.

A pointer to the absolute address 7 in C:
volatile unsigned char *GPIO = (unsigned char*)7;

3. A combination of both is also possible.


There are two fundamental architectures to access memory. John Von Neumann's: One shared memory for instructions (program) and data with one data bus and one address bus between processor and memory. Instructions and data have to be fetched in sequential order (known as the Von Neuman Bottleneck), limiting the operation bandwidth. Its design is simpler than that of the Harvard architecture. It is mostly used to interface to external memory.



The term originated from the Harvard Mark 1 relay-based computer, which stored instructions on punched tape and data in relay latches. Harvard Architecture: The Harvard architecture uses physically separate memories for their instructions and data, requiring dedicated buses for each of them. Instructions and operands can therefore be fetched simultaneously. Different program and data bus widths are possible, allowing program and data memory to be better optimized to the architectural requirements. E.g.: If the instruction format requires 14 bits then program bus and memory can be made 14-bit wide, while the data bus and data memory remain 8-bit wide. PIPELINING Instructions can fill several clock cycles. Instructions can further be divided into smaller steps like: • • • • • fetch instruction decode instruction read data process data write data

Pipelining allows these stages to overlap and to perform with parallelism, hence better performance. The pipeline will only work at full efficiency if it can fetch instructions from sequential locations in memory. Operations that change the program counter, jumps to other


memory locations, will lead to pipeline breaks, requiring the content of the pipeline buffer to be discarded. This will lead to delays in execution and degrade the performance. Example: The instruction is fetched and the program counter incremented. Then the next instruction is fetched while the previous one is still executing. However as we can see in the picture the pipeline has to be flushed if the next instruction can't be fetched from a continuing memory location, because of a call to a subroutine.

PROGRAM AND DATA MEMORY BANKS Program and data memory banks are a compromise solution between the length of instructions, the maximum addressable memory and the required instructions cycles to access the memory.



On-chip banked memory is used when the memory spaces are bigger than the address operands of instructions. Short instructions yield to less complexity (e.g small bus width) on the chip's silicon and improves memory usage efficience (less storage space per instruction). Therefore memory is divided into banks, to keep accesses within a bank short and efficient. Additional instructions are only required to switch banks.

POWER MODES Power consumption is one of the big issues on mobile or battery powered devices. Some microcontrollers allow you to reduce the clock frequency, for example by switching to an internal clock, to reduce power consumption when only little work has to be done. This and many more advanced power saving features can be found in microcontrollers. But not all modes are for power saving. Some microcontrollers may also support in circuit debugging. Most likely you will find these 3 modes: • • • Execution mode (running) Programming mode Sleep or power down mode (low power consumption)