Designing Embedded Systems with PIC Microcontrollers
Principles and ApplicationsBy
- Tim Wilmshurst
This book is a hands-on introduction to the principles and practice of embedded system design using the PIC microcontroller. Packed with helpful examples and illustrations, it gives an in-depth treatment of microcontroller design, programming in both assembly language and C, and features advanced topics such as networking and real-time operating systems. It is accompanied by a companion website containing copies of all programs and software tools used in the text and a âstudentâ version of the C complier.
Designing Embedded Systems with PIC Microcontrollers: Principles and Applications is ideal for students of electronics, mechatronics and computer engineering. Engineers in industry and informed hobbyists will also find this book a valuable resource when designing and implementing both simple and sophisticated embedded systems using the PIC Microcontroller.
Support material, including new and supporting information, links to useful sites, and errata, is available from the book's companion site.
Professional engineers developing embedded systems, informed hobbyists and engineering students.
Published: October 2006
- Section 1 Getting started with embedded systems1. Tiny computers, hidden control1.1 The main idea-embedded systems in today's world1.2 Some example embedded systems1.3 Some computer essentials1.4 Microprocessors and microcontrollers1.5 Microchip and the PIC microcontroller1.6 An introduction to PIC microcontrollers using the 12 series1.7 What others do- a Freescale microcontrollerSummaryReferencesSection 2 Minimum systems and the PIC 16F84A2. Introducing the PIC 16 series and the 16F84A2.1 The main idea- the PIC 16 series family2.2 An architecture overview of the 16F84A2.3 A review of memory technologies2.4 The 16F84A memory2.5 Some issues of timing2.6 Power up and reset2.7 What others do- the Atmel AT89C20512.8 Taking things further- the 16F84A on-chip reset circuitSummaryReferences3. Parallel ports, power supply and the clock oscillator3.1 The main idea- parallel input/output3.2 The technical challenge of parallel input/output3.3 Connecting to the parallel port3.4 The PIC 16F84A parallel ports3.5 The clock oscillator3.6 Power supply3.7 The hardware design of the electronic ping-pongSummaryReferences4. Starting to program- an introduction to Assembler4.1 The main idea- what programs do and how we develop them4.2 The PIC 16 series instruction set, with a little more on the ALU4.3 Assemblers and the assembler format4.4 Creating simple programs4.5 Adopting a development environment4.6 An introductory MPLAB tutorial4.7 An introduction to simulation4.8 Downloading the program to a microcontroller4.9 What others do- a brief comparison of CISC and RISC instruction sets4.10 Taking things further- the 16 series instruction set formatSummaryReferences5. Building assembler programs5.1 The main idea- building structured programs5.2 Flow control- branching and subroutines5.3 Generating time delays and intervals5.4 Dealing with data5.5 Introducing logical systems5.6 Introducing arithmetic instructions and the Carry flag5.7 Taming assembler complexity5.8 More use of the MPLAB simulator5.9 The ping-pong program5.10 Simulating the ping-pong program- tutorial5.11 What others do- graphical simulatorsSummaryReferences6. Working with time: interrupts, counters & timers6.1 The main idea- interrupts6.2 Working with interrupts6.3 The main idea- counters and timers6.4 Applying the 16F84A Timer 0, with examples using the electronic ping-pong6.5 The watchdog timer6.6 Sleep mode6.7 What others do6.8 Taking things further- interrupt latencySummaryReferencesSection 3 Larger systems & the PIC 16F873A7. Larger systems and the PIC 16F873A7.1 The main idea- the PIC 16F87XA7.2 The 16F873A block diagram and CPU7.3 16F873A memory and memory maps7.4 'Special' memory operations7.5 The 16F873A interrupts7.6 The 16F873A oscillator, reset and power supply7.7 The 16F873A parallel ports7.8 Test, commission and diagnostic tools7.9 The Microchip in-circuit debugger (ICD2)7.10 Applying the 16F873A: the Derbot AGV7.11 Downloading, testing and running a simple program with ICD 27.12 Taking things further- the 16F874A/16F877ASummaryReferences8. The human and physical interfaces8.1 The main idea- the human interface8.2 From switches to keypads8.3 LED displays8.4 Liquid crystal displays8.5 The main idea- interfacing to the physical world8.6 Some simple sensors8.7 More on digital input8.8 Actuators: motors and servos8.9 Interfacing to actuators8.10 Building up the Derbot8.11 Applying sensors and actuators- a 'blind' navigation Derbot programSummaryReferences9. Taking timing further9.1 The main ideas- taking counting and timing further9.2 The 16F87XA Timer 0 and Timer 19.3 The 16F87XA Timer 2, comparator and PR2 register9.4 The capture/compare/PWM (CCP) modules9.5 Pulse width modulation9.6 Generating PWM in software9.7 PWM used for digital-to-analog conversion9.8 Frequency measurement9.9 Speed control applied to the Derbot9.10 Where there is no timer9.11 Sleep mode9.12 Where do we go from here?9.13 Building up the DerbotSummaryReferences10. Starting with serial10.1 The main idea- introducing serial10.2 Simple serial links- synchronous data communication10.3 The 16F87XA Master Synchronous Serial Port (MSSP) module in SPI mode10.4 A simple SPI example10.5 The limitations of Microwire and SPI, and of simple synchronous serial transfer10.6 Enhancing synchronous serial, and the Inter-Integrated Circuit bus10.7 The MSSP configured for IC10.8 IC applied in the Derbot AGV10.9 Evaluation of synchronous serial data communication10.10 The 16F87XA Addressable Universal Synchronous Asynchronous Receiver Transmitter (USART)10.11 Implementing serial with a serial port- 'bit banging'10.12 Building up the DerbotSummaryReferences11. Data acquisition and manipulation11.1 The main idea- analog and digital quantities, their acquisition and use11.2 The data acquisition system11.3 The PIC 16F87XA ADC module11.4 Applying the ADC in the Derbot light meter program11.5 Some simple data manipulation techniques11.6 The Derbot light-seeking program11.7 The comparator module11.8 Applying the Derbot circuit for measurement purposes11.9 Configuring the Derbot AGV as a light-seeking robotSummaryReferencesSection 4 Smarter systems and the PIC 18FXX212. Smarter systems and the PIC 18FXX212.1 The main idea- the PIC 18 series and the 18FXX212.2 The 18F2X2 block diagram and Staus register12.3 The 18 series instruction set12.4 Data memory and Special Function Registers12.5 Program memory12.6 The Stacks12.7 The interrupts12.8 Power supply and reset12.9 The oscillator sources12.10 Introductory programming with the 18F242SummaryReferences13 The PIC 18FXX2 peripherals13.1 The main idea- the 18FXX2 peripherals13.2 The parallel ports13.3 The timers13.4 The capture/compare/PWM (CCP) modules13.5 The serial ports13.6 The analog-to-digital converter (ADC)13.7 Low-voltage detect13.8 Applying the 18 series in the Derbot-1813.9 The 18F2420 and the extended instruction setSummaryReferences14 Introducing C14.1 The main idea- why C?14.2 An introduction to C14.3 Compiling the C program14.4 The MPLAB C18 compiler14.5 A C18 tutorial14.6 Simulating a C program14.7 A second C example- the Fibonacci program14.8 The MPLAB C18 libraries14.9 Further readingSummaryReferences15 C and the embedded environment15.1 The main idea- adapting C to the embedded environment15.2 Controlling and branching on bit values15.3 More on functions15.4 More branching and looping15.5 Using the timer and PWM peripheralsSummaryReferences16 Acquiring and using data with C16.1 The main idea- using C for data manipulation16.2 Using the 18FXX2 ADC16.3 Pointers, arrays and strings16.4 Using the IC peripheral16.5 Formatting data for displaySummaryReferences17 More C and the wider C environment17.1 The main idea- more C and the wider C environment17.2 Assembler inserts17.3 Controlling memory allocation17.4 Interrupts17.5 Example with interrupt on overflow- flashing LEDs on the Durbot17.6 Storage classes and their application17.7 Start-up code: c018i.c17.8 Structures, unions and bit-fields17.9 Processor-specific header files17.10 Taking things further- the MPLAB Linker and the .map fileSummaryReferences18 Multi-tasking and the Real Time Operating System18.1 The main ideas- the challenge of multi-tasking and real time18.2 Achieving multi-tasking with sequential programming18.3 The Real Time Operating System (RTOS)18.4 Scheduling and the scheduler18.5 Developing tasks18.6 Data and resource protection- the semaphore18.7 Where do we go from here?SummaryReferences19 The Salvo Real Time Operating System19.1 The main idea- Salvo, an example RTOS19.2 Configuring the Salvo application19.3 Writing Salvo programs19.4 A first Salvo example19.5 Using interrupts, delays and semaphores with Salvo19.6 Using Salvo messages and increasing RTOS complexity19.7 A program example with messages19.8 The RTOS overheadSummaryReferencesSection 5 Techniques of connectivity and networking20 Connectivity and networks20.1 The main idea-networking and connectivity20.2 Infrared connectivity20.3 Radio connectivity20.4 Controller Area Network (CAN) and Local Interconnect Network (LIN)20.5 Embedded systems and the Internet20.6 ConclusionSummaryReferencesAppendix 1 The PIC 16 series instruction setAppendix 2 The electronic ping-pongAppendix 3 The Derbot AGV- hardware design detailsAppendix 4 Some basics of Autonomous Guided VehiclesAppendix 5 PIC 18 series instruction set (non-extended)Appendix 6 Essentials of CIndex