Docsity

Embedded Systems: I/O, Timers, Serial, and Microcontroller Fundamentals, Essays (university) of Computer Science

Partial preview of the text

Download Embedded Systems: I/O, Timers, Serial, and Microcontroller Fundamentals and more Essays (university) Computer Science in PDF only on Docsity!

LECTURE NOTES

ON

Embedded systems

IV B. Tech I Semester (JNTUA-R15)

Mr. M. Jagadeesh Babu, Associate Professor

Chapter No Unit 1 :Introduction to Embedded System (^) Page No 1 1.1 (^) Embedded system introduction 1.2 (^) Host and Target Concept 1.3 (^) Embedded Applications 1.4 (^) Features and Architecture considerations for Embedded systems- ROM, RAM, Timers 1.5 (^) Data and Address Bus concept 1.6 (^) Embedded Processor and their types 1.7 (^) Memory types (Student seminar) 1.8 (^) Overview of design process of embedded systems 1.9 (^) Programming languages and tools for embedded design 2 Unit -II Embedded Processor Architecture 2.1 CISC Vs RISC design philosophy 2.2 Von-Neumann Vs Harvard architecture 2.3 Introduction to ARM architecture and Cortex M series 2.4 Introduction to the TM4C family viz.TM4C123x & TM4C129x and its targeted applications. 2.5 TM4C block diagram 2.6 Address space 2.7 on-chip peripherals (analog and digital) Register sets 2.8 Addressing modes and instruction set basics. 3 Unit III : Overview of Microcontroller and Embedded Systems 3.1 Embedded hardware and various building blocks 3.2 Processor Selection for an Embedded System 3.3 Interfacing Processor, Memories and I/O Devices 3.4 I/O Devices and I/O interfacing concepts 3.5 I/O Devices and I/O interfacing concepts 3.6 Timer and Counting Devices, 3.7 Serial Communication and Advanced I/O, 3.8 Buses between the Networked Multiple Devices 3.9 Embedded System Design 3.10 Co-design Issues in System Development Process 3.11 Design Cycle in the Development Phase for an Embedded System 3.12 (^) Uses of Target System or its Emulator and In-Circuit Emulator (ICE)

UNIT I

Introduction to Embedded System

1.1 Embedded System

An embedded system is a combination of hardware and software with some attached peripherals to perform a specific task or a narrow range of tasks with restricted resources. It is an electronic system that is not directly programmed by the user, unlike a personal computer. An embedded system is a device that incorporates a computer within its implementation, primarily as a means to simplify the system design, and to provide flexibility; and the user of the device is not even aware that a computer is present. It is a microcontroller-based, software- driven, reliable, real time control system,. Autonomous or human or network interactive, operating on diverse physical variables and in diverse environments, and sold in a competitive and cost conscious market. Generally, an embedded system is a subsystem in ~ larger system and it is application specific. The generic block diagram of an embedded system is shown in Figure 1.1. Every embedded system consists of certain input devices such as: key boards, switches, sensors, actuators; output devices such as: displays, buzzers, sensors; processor along with a control program embedded in the off-chip or on-chip memory, and a real time operating system (RTOS). Input Output Figure 1.1: Block Diagram of a Generic Embedded System.

An embedded system exhibits different characteristics such as: Single functionality, No re- programmability, Security, Reliability, Dependability, Robustness and Efficiency in terms of cost, weight, energy, size, and speed. Designing the system to meet these characteristics is very important in the success of the final product. A specialized computer system. That is part of a larger system or machine. Typically, an embedded system is housed on a single microprocessor board with the programs stored in ROM. Virtually all appliances that have a digital Interface -- watches, microwaves, VCRs, cars -- utilize embedded systems. Some embedded systems include an operating system, but many are so specialized that the entire logic can be implemented as a single program. Embedded systems programming is the development of programs intended to be part of a larger operating system or, in a somewhat different usage, to be incorporated on a microprocessor that can then be included as part of a variety of hardware devices. Several other definitions are: A combination of computer hardware and software, and perhaps additional mechanical or other parts, designed to perform a dedicated function. In some cases, embedded systems are part of a larger system or product, as in the case of an antilock braking system in a car. Contrast with general-purpose computer. A specialized computer system which is dedicated to a specific task. Embedded systems range in size from a single processing board to systems with operating systems (ex, Linux, Windows® NT Embedded). Examples of embedded systems are medical equipment and manufacturing equipment. A computer system that is a component of a larger machine or system. Embedded systems can respond to events in real time. Most digital appliances, such as watches or cars, utilize an embedded system. Hardware and software that forms a component of some larger system and is expected to function without human intervention. Typically an embedded system consists of a single-board microcomputer with software in ROM, which starts running a dedicated application as soon as power is turned on and does not stop until power is turned off. An embedded system is some combination of computer hardware and software, either fixed in capability or programmable, that is specifically designed for a particular kind of application device. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines, and toys (as well as the more obvious cellular phone and PDA) are among the myriad possible hosts of an embedded system.

Stand-alone Embedded systems: A stand-alone embedded system works by itself. It is a self-contained device which does not require any host system like a computer. It takes either digital or analog inputs from its input ports, calibrates, converts, and processes the data, and outputs the resulting data to its attached output device, which either displays data, or controls and drives the attached devices. EX: Temperature measurement systems, Video game consoles, MP3 players, digital cameras, and microwave ovens are the examples for this category. Real-time embedded systems: An embedded system which gives the required output in a specified time or which strictly follows the time deadlines for completion of a task is known as a Real time system i.e. a Real Time system, in addition to functional correctness, also satisfies the time constraints . There are two types of Real time systems. (i) Soft real time system and (ii) Hard real time system. Soft Real-Time system: A Real time system in which, the violation of time constraints will cause only the degraded quality, but the system can continue to operate is known as a Soft real time system. In soft real-time systems, the design focus is to offer a guaranteed bandwidth to each real-time task and to distribute the resources to the tasks. Ex: A Microwave Oven, washing machine, TV remote etc. Hard Real-Time system: A Real time system in which, the violation of time constraints will cause critical failure and loss of life or property damage or catastrophe is known as a Hard Real time system. These systems usually interact directly with physical hardware instead of through a human being .The hardware and software of hard real-time systems must allow a worst case execution (WCET) analysis that guarantees the execution be completed within a strict deadline. The chip selection and RTOS selection become important factors for hard real-time system design.

  1. Networked embedded system
  2. Mobile embedded system Sophisticated Embedded Systems

Ex: Deadline in a missile control embedded system , Delayed alarm during a Gas leakage , car airbag control system , A delayed response in pacemakers ,Failure in RADAR functioning etc. Networked embedded systems: The networked embedded systems are related to a network with network interfaces to access the resources. The connected network can be a Local Area Network (LAN) or a Wide Area Network (WAN), or the Internet. The connection can be either wired or wireless. The networked embedded system is the fastest growing area in embedded systems applications. The embedded web server is such a system where all embedded devices are connected to a web server and can be accessed and controlled by any web browser. Ex: A home security system is an example of a LAN networked embedded system where all sensors (e.g. motion detectors, light sensors, or smoke sensors) are wired and running on the TCP/IP protocol. Mobile Embedded systems: The portable embedded devices like mobile and cellular phones, digital cameras, MP players, PDA (Personal Digital Assistants) are the example for mobile embedded systems. The basic limitation of these devices is the limitation of memory and other resources. Based on the performance of the Microcontroller they are also classified into (i) Small scaled embedded system (ii) Medium scaled embedded system and (iii) Large scaled embedded system.

1.1.4 Classifications of Embedded systems

  1. Small Scale Embedded Systems: These systems are designed with a single 8- or 16- bit microcontroller; they have little hardware and software complexities and involve board- level design. They may even be battery operated. When developing embedded software for these, an editor, assembler and cross assembler, specific to the microcontroller or processor used, are the main programming tools. Usually, C used for developing these systems. C program compilation is done into the assembly, and executable codes are then appropriately located in the system memory. The software has to fit within the memory available and keep in view the need to limit power dissipation when system is running continuously.

program will execute. Embedded software development tools can rarely make assumptions about the target platform. Hence the user has to provide some explicit instructions of the system to the tools. Figure 1.2 shows how an embedded system is developed using a host and a target machine. Figure 1.2 Embedded system using host and target machine Host machine: The application program developed runs on the host computer. The host computer is also called as Development Platform. It is a general purpose computer. It has a higher capability processor and more memory. It has different input and output devices. The compiler, assembler, linker, and locator run on a host computer rather than on the embedded system itself. These tools are extremely popular with embedded software developers because they are freely available (even the source code is free) and support many of the most popular embedded processors. It contains many development tools to create the output binary image. Once a program has been written, compiled, assembled and linked, it is moved to the target platform. Program Development Tool Kit

  1. Program development tool kit or IDE
  2. assembly mnemonics or C++ or Java or Visual C++ using the keyboard of the host system (PC) for entering the program.
  3. Using GUIs for allowing the entry, addition, deletion, insert, appending previously written lines or files, merging record and files at the specific positions.
  4. Create source file that stores the edited file.
  5. File given an appropriate name by the programmer
  1. Can use previously created files
  2. Can also integrate the various source files.
  3. Can save different versions of the source files.
  4. Compiler, cross compiler, assembler, Target machine The output binary image is executed on the target hardware platform. It consists of two entities
  • the target hardware (processor) and runtime environment (OS). It is needed only for final output
  1. Target system differs from a final system
  2. Target system interfaces with the computer as well works as a standalone system
  3. In target system might be repeated downloading of the codes during the development phase
  4. Target system copy made that later on functions as embedded system
  5. Designer later on simply copies it into final system or product.
  6. Final system may employs ROM in place of flash, EEPROM or EPROM in embedded system. Figure 1.3 Host and Target interfacing Examples:
  7. Phillips LPC 21xx development board
  8. MSP 430 development board

7 Automobile Fuel injection controller, anti-locking brake system, air-bag system, GPS, cruise control. 8 Entertainment MP3, video game, Mind Storm, smart toy. 9 Aerospace Navigation system, automatic landing system, flight attitude controller, space explorer, space robotics. 10 Industrial automation^ Assembly line, data collection system, monitoring systems on pressure, voltage, current, temperature, hazard detecting system, industrial robot. 11 Personal PDA, iPhone, palmtop, data organizer. 12 Medical^ CT scanner, ECG, EEG, EMG, MRI, Glucose monitor, blood pressure monitor, medical diagnostic device. 13 Banking & Finance ATM, smart vendor machine, cash register ,Share market 14 Miscellaneous: Elevators, tread mill, smart card, security door etc. 1.4 Features of an Embedded System Embedded systems products have been effectively used not only in our day to day used products but these are also used as wholly or partially unavoidable components in many high end uses like military, scientific research, telecommunication etc. Its size may confined from hand held cell phones to components of nuclear missile. Irrespective of its size it necessarily consist of some hardware and software designed to work on hardware. So Embedded Systems are called Product of Hardware and Software Co-design. Features of different hardware and software units of embedded systems are explained in the following sections.

1.4.1 Hardware features of standalone embedded systems

Standalone embedded system includes different types of processors, power supply unit, clock, reset circuit, memories which are considered to be most essential hardware components of standalone embedded systems. A brief discussion on important features of these components are given below 1 .4.1.1 Different types of processors used Processor: A processor is the heart of the embedded system. It is responsible for execution of instruction and controlling flow of data to and from processor. Designer should have proper knowledge regarding efficiency of different types of processor and based on which one should select the appropriate processor as per requirement. Different types of processors available can

be categorized into four broad categories (l) General purpose processor (GPP) (2) Application specific System processor (ASSP) (3) Multiprocessor system and (4) GPP core or ASIP core. A GPP has the usage advantages over other processors because of a). Having predefined known instruction set resulting fast system development. b). Board and I/O Interfaces designed for GPP can be used for different system changing the software. c) Ready availability of computer facilities in high level language along with compiler and debugger, resulting in fast development of a new system. a) General Purpose Processor (GPP) may be any one of Microprocessor, Microcontroller, Embedded processor, Digital Signal Processor (DSP) and Media processor. Microprocessor is a single VLSI chip that has a CPU with caches, floating point processing arithmetic unit, pipelining and super scaling, units. Later units may present for faster processing. RAM is externally connected to CPU. Microcontroller is also a single chip VLSI unit with limited computational capability keeping all functional units /components inside the chip. Embedded processor may be microprocessor or microcontroller when design specially to achieve capabilities of fast context switching resulting lower latency, atomic ALU operation with no shared data problem RISC core for fast and precise calculations. ARM family processors, Intel i960 etc. belongs to this class. DSP as a GPP is a single chip VLSI having computational capabilities of a microprocessor and a multiply and Accumulate (MAC) unit(s). DSP is an essential units of an embedded system with very large instruction word (VLWI) processing capabilities. It process very efficiently Single Instruction Multiple Data (SIMD), Discrete Cosine Transformation (DCT) and Inverse Discrete Cosine Transformation (IDCT). DCT and IDCT are most useful for algorithms for signal analysing, coding, filtering noise cancellation, echo-elimination etc. b) Application Specific System Processor (ASSP): ASSP is dedicated for faster processing and useful for applications like real time video processing which incorporates lots of processing before transmitting. It may also include some features of RTOS. ASSP provides hardwired solution for most of its time consuming tasks. For example ASSP chip i2ehip has TCP, UDP, IP, ARP and Ethernet 10/100 MAC Media Access Control) hardwired logic included into it. In practice, an ASSP is used as an additional processing unit for running the application specific tasks in place of processing using embedded software.

either connected to an external power supply or use charge pump for necessary power supply. Example of first type may be Network Interface Card (NIC) and Graphics accelerator which do not have their own power supply are connected to PC power-supply line. In the second type charge pump brings power from a non-supply line. It consist of a diode in the series followed by a charging capacitor. The diode gets forward bias input from an external signal, say RTS (Request to Send) signal in case a mouse used with the computer. The charge pump inside the mouse store charge in inactive state and dissipate power when the mouse is used. An embedded system has to perform tasks continuously from power-up to power-off and may even be kept on continuously. Real Time Systems (RTOS) use Wait and Stop instructions and disabling certain units when not needed. This indeed is very important for saving power during program execution. Performing tasks at reduce clock rate is also a way to control power dissipation. Performance of software analysis during design phase can include power dissipation considerations also. A good design must optimize the conflicting needs of low power dissipation and fast efficient program execution. 1.4.1.3 Clock Oscillator The function of this oscillator circuit is to provide an accurate and stable periodic clock signal to a processor. The processor needs a clock oscillator as clock controls the various clocking requirements of CPU. The clocking requirements are the system timers and CPU machine cycles. The machine cycle includes (i) Fetching code and data from memory and Decoding and execution and (ii) Transferring results to memory. The clock controls the time for executing an instruction. The clock circuit uses either a crystal (External to the processor) or a ceramic resonator (internally associated with the processor) or an external IC attached to the processor. (a)The crystal resonator gives the highest stability in frequency with temperature and drift in the circuit. The crystal in association with an appropriate resistance in parallel and a pair of series capacitance at both pins. The crystal is kept as near as feasible to the two pins of the processor, (b) The internal ceramic generator, if available in a processor, saves the use of the external crystal and gives a reasonable though not very high frequency (c) The external IC based clock oscillator has a significantly higher power dissipation compared to the internal processor resonator. It provides a higher driving capability, which might be needed when various embedded circuits of embedded systems concurrently driven for e.g. in multiprocessor based systems.

1.4.1.4 Real time clock or timer units A timer is suitably configured as system clock sometime referred as RTC (Real Time Clock). RTC is used by scheduler for real time programming. A hardware timer is a counter that is incremented at a fixed rate when the system clock pulses. There are several different types of timers available. A timer/counter can perform several different tasks. The CPU uses the timer to keep track of time accurately. The timer can generate a stream of pulses or a single pulse at different frequencies. It can be used to start and stop tasks at desired times A COP (computer operating properly) or watchdog timer checks for runaway code execution. The hardware implementation of watchdog timers varies considerably between different processors. In general watchdog timers must be turned on once within the first few cycles after reset and then reset periodically with software. Some watchdog timers can programmed for different time-out delays. The reset sequence is sometimes as simple as a specialized instruction or as complex as sending a sequence of bytes to a port. Watchdog timers either reset the processor or execute an interrupt when they time out. More than one timers using the RTC may be needed for various timing and counting need. There may be hardware and software implementations of timers. At least one hardware timer device is must in a system which is used as system clock. The hardware timer gets the input from a clock out signal from processor and activates the system clock as per the number ticks present at the hardware timer. Number of hardware timers present are generally limited. A software timer is a software that executes and increases or decreases a count variable (count value) or an interrupt on a timer output or on a real time clock interrupt. A software timer can also generate interrupt on overflow of count value or the final value of count variable. Software timers are used as virtual timing devices. There are number of control bits and time out status flags in each timer device. A timer device when given count inputs, in place of clock pulses performs as a counting device. 1.4.1.5 Interrupt Handlers A system possesses a number of devices and the system processor has to control and handle the requirements of devices by running appropriate Interrupt Service Routine (ISR) for each. An interrupt handling mechanism must exist in each system to handle interrupt from various processes in the system. An interrupt is an event that suspends regular

Embedded system makes use of different types of memories based on their features. These can be viewed with following chart. These may be briefly explained based on their functionality (i) Internal RAM used for registers, temporary data and stack. (ii) Internal ROM/PROM/EPROM for application program (iii) External RAM for temporary data and stack (iv) Intemal cache available in case of some microcontroller or microprocessor. (v)EEPROM of flash memory for saving the results (vi) External ROM or PROM for embedding software used in non - microcontroller based systems. (vii) RAM memory buffers at ports. Caches for superscalar microprocessors. Figure 1.4: Various forms of system memory Different types of memory devices in varying sizes are available for use as per requirement. These are (a) Masked ROM or EPROM of flash which stores the embedded software (ROM image). Masked ROM is for bulked manufacturing. (2)EPROM or EEPROM is used for testing and design stages. (3)EEPROM (5V form) is used to store the results during the system program run time. It is erased byte by byte and written during the system run. It is useful to store modifiable bytes for example run time system status, time and date. Flash is very useful when a processed image or voice is to be stored or a data set or system configuration data is to be stored which can be upgraded as and when required. In a flash new images after compressing and processing can be stored and the old one is erased from a sector in a single instruction cycle. In boot block flash a OPT sector is reserved to store once only at the time of first boot. It stores boot program and initial data or permanent system configuration data. This OTP sector can be used to store ROM image. (4)RAM is mostly used in SRAM form in a system. Advanced system uses RAM in the form of a DRAM, SDRAM, or RDRAM (5) Parameterised distributed RAM is used when I/O devices and subunits require a memory buffer. (6) Subunits like MAC which operates at fast speed uses separate blocks of RAM.

1.4.18 Input / Output units and buses The system gets input from physical devices such as keypads/boards, sensors, transducer circuits etc. It gets the values by read operations at the port address. The system has output ports through which it sends output bytes to the real world. It sends the values to output by a write operation at the port address. In case of some devices a port may be used as both input as well as output port. One example is mobile phone which sends as well as receives signals. There are two types of I/O ports (i) Parallel port and (ii) Serial port. In a serial port, system gets a serial stream of bits at an input and sends the signal as bits through a modem. A serial port facilitates long distance communications and interconnections. A serial port may be serial URAT, a serial synchronous port or serial interfacing port. A system may get inputs from multiple channels or may have to send multiple output channels. A demultiplexer takes input from various channels and transfers the input to a selected channel. A multiplexer takes output from the system and sends it to another system. A system might have to be connected to a number of other devices and systems. For networking system there are different types of buses e.g., I2C, CAN, USB, ISA, EISA and PCI. 1.4.1.8 DAC/ADC For automatic control and signal processing applications, a system must provide necessary interfacing circuit and software for Digital to Analog Conversion (DAC) unit and Analog to Digital Conversion (ADC) unit. A DAC operation is done with the help of a combination of PWM (Pulse Width Modulation) unit in the microcontroller and External Integrator chip. ADC operations are needed in systems for voice processing, Instrumentation, Data acquisition systems and automatic control. 1.5 Data and Address Bus concept We refine the high level functional diagram to illustrate a typical bus configuration comprising the address, data and control lines