In this new edition the latest ARM processors and other hardware developments are fully covered along with new sections on Embedded Linux and the new freeware operating system eCOS. The hot topic of embedded systems and the internet is also introduced. In addition a fascinating new case study explores how embedded systems can be developed and experimented with using nothing more than a standard PC. * A practical introduction to the hottest topic in modern electronics design* Covers hardware, interfacing and programming in one book* New material on Embedded Linux for embedded internet systems
Inhaltsverzeichnis
1;Cover;1 2;Contents;5 3;Preface;17 4;Acknowledgements;19 5;1 What is an embedded system?;21 5.1;What is an embedded system?;22 5.1.1;Replacement for discrete logic-based circuits;22 5.1.2;Provide functional upgrades;23 5.1.3;Provide easy maintenance upgrades;23 5.1.4;Improves mechanical performance;23 5.1.5;Protection of intellectual property;24 5.1.6;Replacement for analogue circuits;24 5.2;Inside the embedded system;28 5.2.1;Processor;28 5.2.2;Memory;28 5.2.3;Peripherals;29 5.2.4;Software;30 5.2.5;Algorithms;30 5.3;Examples;31 5.3.1;Microcontroller;31 5.3.2;Expanded microcontroller;33 5.3.3;Microprocessor based;34 5.3.4;Board based;34 6;2 Embedded processors;35 6.1;8 bit accumulator processors;36 6.1.1;Register models;36 6.1.2;8 bit data restrictions;37 6.1.3;Addressing memory;38 6.1.4;System integrity;39 6.2;Example 8 bit architectures;39 6.2.1;Z80;39 6.2.2;Z80 programming model;41 6.2.3;MC6800;42 6.3;Microcontrollers;43 6.3.1;MC68HC05;43 6.3.2;MC68HC11;43 6.3.3;Architecture;45 6.4;Data processors;45 6.4.1;Complex instructions, microcode and nanocode;45 6.5;INTEL 80286;48 6.5.1;Architecture;48 6.5.2;Interrupt facilities;49 6.5.3;Instruction set;50 6.5.4;80287 floating point support;50 6.5.5;Feature comparison;50 6.6;INTEL 80386DX;50 6.6.1;Architecture;50 6.6.2;Interrupt facilities;52 6.6.3;Instruction set;52 6.6.4;80387 floating point coprocessor;53 6.6.5;Feature comparison;53 6.7;INTEL 80486;54 6.7.1;Instruction set;55 6.8;Intel 486SX and overdrive processors;55 6.9;Intel Pentium;56 6.10;Pentium Pro;58 6.10.1;Multiple branch prediction;58 6.10.2;Data flow analysis;58 6.10.3;Speculative execution;58 6.10.4;The MMX instructions;59 6.10.5;The Pentium II;60 6.11;Motorola MC68000;60 6.12;The MC68000 hardware;61 6.12.1;Address bus;61 6.12.2;Data bus;61 6.12.3;Function codes;62 6.12.4;Interrupts;63 6.12.5;Error recovery and control signals;64 6.13;Motorola MC68020;64 6.13.1;The programmers model;66 6.13.2;Bus interfaces;69 6.14;Motorola MC68030;70 6.15;The MC68040;71
6.15.1;The programming model;73 6.16;Integrated processors;74 6.17;RISC processors;77 6.17.1;The 80/20 rule;77 6.17.2;The initial RISC research;78 6.18;The Berkeley RISC model;79 6.19;Sun SPARC RISC processor;80 6.19.1;Architecture;80 6.19.2;Interrupts;80 6.19.3;Instruction set;81 6.20;The Stanford RISC model;82 6.21;The MPC603 block diagram;83 6.22;The ARM RISC architecture;85 6.22.1;The ARM register set;85 6.22.2;Exceptions;86 6.22.3;The Thumb instructions;87 6.23;Digital signal processors;88 6.24;DSP basic architecture;89 6.25;Choosing a processor;92 6.25.1;Does it have enough performance?;92 7;3 Memory systems;94 7.1;Memory technologies;94 7.1.1;DRAM technology;96 7.1.2;Video RAM;97 7.2;SRAM;97 7.2.1;Pseudo-static RAM;98 7.2.2;Battery backed-up SRAM;98 7.3;EPROM and OTP;98 7.4;Flash;99 7.5;EEPROM;99 7.6;Memory organisation;99 7.6.1;By 1 organisation;100 7.6.2;By 4 organisation;101 7.6.3;By 8 and by 9 organisations;101 7.6.4;By 16 and greater organisations;101 7.7;Parity;101 7.7.1;Parity initialisation;102 7.8;Error detecting and correcting memory;102 7.9;Access times;103 7.10;Packages;103 7.10.1;Dual in line package;104 7.10.2;Zigzag package;104 7.10.3;SIMM and DIMM;104 7.10.4;SIP;105 7.11;DRAM interfaces;105 7.11.1;The basic DRAM interface;105 7.11.2;Page mode operation;106 7.11.3;Page interleaving;106 7.11.4;Burst mode operation;107 7.11.5;EDO memory;107 7.12;DRAM refresh techniques;108 7.12.1;Distributed versus burst refresh;108 7.12.2;Software refresh;109 7.12.3;RAS only refresh;109 7.12.4;CAS before RAS (CBR) refresh;109 7.12.5;Hidden refresh;109 7.12.6;Memory management;110 7.12.7;Disadvantages of memory management;112 7.12.8;Segmentation and paging;113 7.12.9;Memory protection units;117 7.12.10;Cache memory;119 7.12.11;Cache size and organization;120 7.13;Optimizing line length and cache size;124 7.14;Logical vs physical caches;125 7.15;Unified versus Harvard caches;126 7.16;Cache coherency;126 7.17;Case 1: write-through;128 7.18;Case 2: write-back;129 7.
19;Case 3: no caching of write cycles;130 7.20;Case 4: write buffer;130 7.21;Bus snooping;131 7.22;The MESI protocol;136 7.23;The MEI protocol;137 7.23.1;Burst interfaces;138 7.23.2;Meeting the interface needs;139 7.24;Big and little endian;141 7.25;Dual port and shared memory;142 7.26;Bank switching;143 7.27;Memory overlays;144 7.28;Shadowing;144 7.29;Example interfaces;145 7.29.1;MC68000 asynchronous bus;145 7.29.2;M6800 synchronous bus;147 7.29.3;The MC68040 burst interface;148 8;4 Basic peripherals;151 8.1;Parallel ports;151 8.1.1;Multi-function I/O ports;152 8.1.2;Pull-up resistors;153 8.2;Timer/counters;153 8.2.1;Types;154 8.3;8253 timer modes;154 8.3.1;Interrupt on terminal count;154 8.3.2;Programmable one-shot;154 8.3.3;Rate generator;156 8.3.4;Square wave rate generator;156 8.3.5;Software triggered strobe;156 8.3.6;Hardware triggered strobe;157 8.3.7;Generating interrupts;157 8.4;MC68230 modes;157 8.5;Timer processors;158 8.6;Real-time clocks;159 8.6.1;Simulating a real-time clock in software;160 8.7;Serial ports;160 8.8;Serial peripheral interface;162 8.9;I2C bus;163 8.9.1;Read and write access;165 8.9.2;Addressing peripherals;166 8.9.3;Sending an address index;167 8.9.4;Timing;168 8.9.5;Multi-master support;169 8.10;M-Bus (Motorola);170 8.11;What is an RS232 serial port?;170 8.12;Asynchronous flow control;173 8.12.1;Modem cables;175 8.12.2;Null modem cables;175 8.12.3;XON-XOFF flow control;178 8.13;UART implementations;178 8.13.1;8250/16450/16550;178 8.13.2;The interface signals;179 8.13.3;The Motorola MC68681;182 8.14;DMA controllers;183 8.15;A generic DMA controller;184 8.15.1;Operation;184 8.16;DMA controller models;186 8.16.1;Single address model;186 8.16.2;Dual address model;187 8.16.3;1D model;188 8.16.4;2D model;188 8.16.5;3D model;189 8.17;Channels and control blocks;189 8.18;Sharing bus bandwidth;191 8.19;DMA implementations;193 8.19.1;Intel 8237;193 8.19.2;Motorola MC68300 series;193 8.19.3;Using another CPU with firmware;194 9;5 Interfacing to
the analogue world;195 9.1;Analogue to digital conversion techniques;195 9.1.1;Quantisation errors;196 9.2;Sample rates and size;196 9.2.1;Irregular sampling errors;197 9.2.2;Nyquists theorem;199 9.3;Codecs;199 9.3.1;Linear;199 9.3.2;A-law and;199 9.3.3;-law;199 9.3.4;PCM;200 9.3.5;DPCM;200 9.3.6;ADPCM;201 9.4;Power control;201 9.4.1;Matching the drive;201 9.4.2;Using H bridges;203 9.4.3;Driving LEDs;204 9.4.4;Interfacing to relays;204 9.4.5;Interfacing to DC motors;205 9.4.6;Software only;206 9.4.7;Using a single timer;207 9.4.8;Using multiple timers;208 10;6 Interrupts and exceptions;209 10.1;What is an interrupt?;209 10.1.1;The spaghetti method;210 10.1.2;Using interrupts;211 10.2;Interrupt sources;212 10.2.1;Internal interrupts;212 10.2.2;External interrupts;212 10.2.3;Exceptions;212 10.2.4;Software interrupts;213 10.2.5;Non-maskable interrupts;213 10.3;Recognising an interrupt;214 10.3.1;Edge triggered;214 10.3.2;Level triggered;214 10.3.3;Maintaining the interrupt;214 10.3.4;Internal queuing;214 10.4;The interrupt mechanism;215 10.4.1;Stack-based processors;215 10.5;MC68000 interrupts;216 10.6;RISC exceptions;218 10.6.1;Synchronous precise;219 10.6.2;Synchronous imprecise;219 10.6.3;Asynchronous precise;219 10.6.4;Asynchronous imprecise;220 10.6.5;Recognising RISC exceptions;220 10.6.6;Enabling RISC exceptions;222 10.6.7;Returning from RISC exceptions;222 10.6.8;The vector table;222 10.6.9;Identifying the cause;223 10.7;Fast interrupts;223 10.8;Interrupt controllers;225 10.9;Instruction restart and continuation;225 10.10;Interrupt latency;226 10.11;Dos and Donts;229 10.11.1;Always expect the unexpected interrupt;229 10.11.2;Don't expect too much from an interrupt;229 10.11.3;Use handshaking;230 10.11.4;Control resource sharing;230 10.11.5;Beware false interrupts;231 10.11.6;Controlling interrupt levels;231 10.11.7;Controlling stacks;231 11;7 Real-time operating systems;232 11.1;What are operating systems?;232 11.2;Operating system internals;234 11.3;Multitaski
ng operating systems;235 11.3.1;Context switching, task tables, and kernels;235 11.3.2;Time slice;243 11.3.3;Pre-emption;244 11.3.4;Co-operative multitasking;244 11.4;Scheduler algorithms;245 11.4.1;Rate monotonic;245 11.4.2;Deadline monotonic scheduling;247 11.4.3;Priority guidelines;247 11.5;Priority inversion;247 11.5.1;Disabling interrupts;247 11.5.2;Message queues;248 11.5.3;Waiting for a resource;249 11.5.4;VMEbus interrupt messages;249 11.5.5;Fairness systems;251 11.6;Tasks, threads and processes;251 11.7;Exceptions;252 11.8;Memory model;253 11.8.1;Memory allocation;253 11.8.2;Memory characteristics;254 11.8.3;Example memory maps;255 11.9;Memory management address translation;259 11.9.1;Bank switching;262 11.9.2;Segmentation;263 11.9.3;Virtual memory;263 11.9.4;Choosing an operating system;264 11.9.5;Assembler versus high level language;265 11.9.6;ROMable code;265 11.9.7;Scheduling algorithms;265 11.9.8;Pre-emptive scheduling;266 11.9.9;Modular approach;266 11.9.10;Re-entrant code;267 11.9.11;Cross-development platforms;267 11.9.12;Integrated networking;267 11.9.13;Multiprocessor support;267 11.10;Commercial operating systems;268 11.10.1;pSOS+;268 11.10.2;pSOS+ kernel;268 11.10.3;pSOS multiprocessor kernel;269 11.10.4;pREPC+ runtime support;269 11.10.5;pHILE+ file system;270 11.10.6;pNA+ network manager;270 11.10.7;pROBE+ system level debugger;270 11.10.8;XRAY+ source level debugger;270 11.10.9;OS-9;270 11.10.10;VXWorks;271 11.10.11;VRTX-32;271 11.10.12;IFX;272 11.10.13;TNX;272 11.10.14;RTL;272 11.10.15;RTscope;272 11.10.16;MPV;272 11.10.17;LynxOS-POSIX conformance;272 11.10.18;Windows NT;274 11.10.19;Windows NT characteristics;275 11.10.20;Process priorities;276 11.10.21;Interrupt priorities;277 11.11;Resource protection;278 11.11.1;Protecting memory;278 11.11.2;Protecting hardware;278 11.11.3;Coping with crashes;279 11.11.4;Multi-threaded software;279 11.11.5;Addressing space;280 11.11.6;Virtual memory;281 11.11.7;The internal architecture;281 11.11.8;Virtu
al memory manager;282 11.11.9;User and kernel modes;282 11.11.10;Local procedure call (LPC);283 11.11.11;The kernel;283 11.11.12;File system;283 11.11.13;Network support;284 11.11.14;I/O support;284 11.11.15;HAL approach;284 11.12;Linux;285 11.12.1;Origins and beginnings;285 11.12.2;Inside Linux;288 11.12.3;The Linux file system;289 11.12.4;The physical file system;290 11.12.5;Building the file system;291 11.12.6;The file system;292 11.13;Disk partitioning;294 11.13.1;The /proc file system;297 11.13.2;Data caching;297 11.13.3;Multi-tasking systems;298 11.13.4;Multi-user systems;298 11.13.5;Linux software structure;299 11.13.6;Processes and standard I/O;300 11.13.7;Executing commands;301 11.13.8;Physical I/O;302 11.13.9;Memory management;303 11.13.10;Linux limitations;303 11.13.11;eLinux;304 12;8 Writing software for embedded systems;308 12.1;The compilation process;308 12.1.1;Compiling code;309 12.1.2;The pre-processor;310 12.1.3;Compilation;313 12.1.4;as assembler;315 12.1.5;Linking and loading;316 12.1.6;Symbols, references and relocation;316 12.1.7;Id linker/loader;317 12.2;Native versus cross-compilers;318 12.3;Run-time libraries;318 12.3.1;Processor dependent;318 12.3.2;I/O dependent;319 12.3.3;System calls;319 12.3.4;Exit routines;319 12.4;Writing a library;320 12.4.1;Creating a library;320 12.4.2;Device drivers;326 12.4.3;Debugger supplied I/O routines;326 12.4.4;Run-time libraries;327 12.5;Using alternative libraries;327 12.5.1;Linking additional libraries;327 12.5.2;Linking replacement libraries;327 12.6;Using a standard library;327 12.7;Porting kernels;328 12.7.1;Board support;328 12.7.2;Rebuilding kernels for new configurations;329 12.7.3;configA11.h;330 12.7.4;config.h;330 12.7.5;usrConfig.c;330 12.7.6;pSOSystem+;332 12.8;C extensions for embedded systems;333 12.8.1;#pragma interrupt func2;333 12.8.2;#pragma pure_function func2;334 12.8.3;#pragma no_side_effects func2;334 12.8.4;#pragma no_return func2;334 12.8.5;#pragma mem_port int2;334 12.8.6;asm and
_ _asm;334 12.9;Downloading;336 12.9.1;Serial lines;336 12.9.2;EPROM and FLASH;337 12.9.3;Parallel ports;337 12.9.4;From disk;337 12.9.5;Ethernet;338 12.9.6;Across a common bus;338 13;9 Emulation and debugging techniques;341 13.1;Debugging techniques;341 13.1.1;High level language simulation;341 13.1.2;Low level simulation;342 13.1.3;Onboard debugger;343 13.1.4;Task level debugging;345 13.1.5;Symbolic debug;345 13.1.6;Emulation;347 13.1.7;Optimisation problems;348 13.1.8;Xray;352 13.2;The role of the development system;355 13.2.1;Floating point and memory management functions;355 13.3;Emulation techniques;356 13.3.1;JTAG;357 13.3.2;OnCE;357 13.3.3;BDM;358 14;10 Buffering and other data structures;359 14.1;What is a buffer?;359 14.1.1;Latency;361 14.1.2;Timing tolerance;361 14.1.3;Memory size;362 14.1.4;Code complexity;362 14.2;Linear buffers;362 14.3;Directional buffers;364 14.3.1;Single buffer implementation;364 14.4;Double buffering;366 14.5;Buffer exchange;368 14.6;Linked lists;369 14.7;FIFOs;370 14.8;Circular buffers;371 14.9;Buffer underrun and overrun;372 14.10;Allocating buffer memory;373 14.10.1;malloc();373 14.11;Memory leakage;374 14.11.1;Stack frame errors;374 14.11.2;Failure to return memory to the memory pool;375 14.11.3;Housekeeping errors;375 14.11.4;Wrong memory specification;376 15;11 Memory and performance trade-offs;377 15.1;The effect of memory wait states;377 15.2;Scenario 1 Single cycle processor with large external memory;378 15.3;Scenario 2 Reducing the cost of memory access;380 15.3.1;Using registers;380 15.3.2;Using caches;381 15.3.3;Preloading caches;382 15.3.4;Using on-chip memory;383 15.3.5;Using DMA;383 15.4;Making the right decisions;383 16;12 Software examples;385 16.1;Benchmark example;385 16.2;Creating software state machines;388 16.2.1;Priority levels;392 16.2.2;Explicit locks;393 16.2.3;Interrupt service routines;393 16.2.4;Setting priorities;395 16.2.5;Task A highest priority;395 16.2.6;Task C highest priority;396 16.2.7;Using ex
plicit locks;396 16.2.8;Round-robin;396 16.2.9;Using an ISR routine;397 17;13 Design examples;399 17.1;Buglar alarm system;399 17.1.1;Design goals;399 17.1.2;Development strategy;400 17.1.3;Software development;400 17.1.4;Cross-compilation and code generation;403 17.1.5;Porting to the final target system;405 17.1.6;Generation of test modules;405 17.1.7;Target hardware testing;405 17.1.8;Future techniques;405 17.1.9;Relevance to more complex designs;406 17.1.10;The need for emulation;406 17.2;Digital echo unit;407 17.2.1;Creating echo and reverb;407 17.2.2;Design requirements;410 17.2.3;Designing the memory structures;411 17.2.4;The software design;412 17.2.5;Multiple delays;414 17.2.6;Digital or analogue adding;415 17.2.7;Microprocessor selection;15 17.2.8;The overall system design;416 18;14 Real- time without a RTOS;418 18.1;Choosing the software environment;418 18.2;Deriving real-time performance from a non-real-time system;420 18.2.1;Choosing the hardware;421 18.3;Scheduling the data sampling;422 18.4;Sampling the data;425 18.5;Controlling from an external switch;426 18.5.1;Driving an external LED display;428 18.5.2;Testing;428 18.6;Problems;430 18.6.1;Saving to hard disk;430 18.6.2;Data size restrictions and the use of a RAM disk;430 18.6.3;Timer calculations and the compiler;431 18.6.4;Data corruption and the need for buffer flushing;431 18.7;Program listing;433 19;Index;442