Embedded Systems Programming with the Microchip PIC16F877 Microcontroller

Total Page:16

File Type:pdf, Size:1020Kb

Embedded Systems Programming with the Microchip PIC16F877 Microcontroller EMBEDDED SYSTEMS PROGRAMMING WITH THE PIC16F877 Second Edition By Timothy D. Green Copyright 2008 by Timothy D. Green All Rights Reserved. Table of Contents Preface …………………………………………………………………. 5 List of Figures …………………………………………………………. 6 Abbreviations and Acronyms …………………………………………. 7 Trademarks ……………………………………………………………. 10 Chapter 1 Introduction to ESP and the PIC …………………………. 11 Chapter 2 Microcontrollers and the PIC16F877 ……………………. 15 Section 2.0 Chapter Summary ……………………………….. 15 Section 2.1 Memory and Memory Organization ……………. 15 Section 2.2 The PIC16F877 …………………………………. 16 Section 2.3 Programming the PIC …………………………… 17 Chapter 3 Simple PIC Hardware & Software (“Hello World”) …….. 20 Section 3.0 Chapter Summary ……………………………….. 20 Section 3.1 A Simple Example System ……………………… 20 Section 3.2 Summary of Instructions and Concepts …………. 25 Chapter 4 The PIC Instruction Set (Part I) ………………………….. 27 Section 4.0 Chapter Summary ………………………………. 27 Section 4.1 The PIC16F877 Instruction Set ………………… 27 Section 4.2 Summary of Instructions and Concepts …………. 33 Chapter 5 The PIC Instruction Set (Part II) …………………………. 34 Section 5.0 Chapter Summary ……………………………….. 34 Section 5.1 Introduction ……………………………………… 34 Section 5.2 Keypad and Display Interface …………………… 35 Section 5.3 The STATUS Register and Flag Bits ……………. 39 Section 5.4 The Keypad Software ……………………………. 40 Section 5.5 The LED Display Software ……………………… 43 Section 5.6 Improved Display and Indirect Addressing ……… 46 Section 5.7 Odds & Ends …………………………………….. 50 Section 5.8 Using KEY_SCAN and DISPLAY Together ……. 54 Section 5.9 A Last Look at the Advanced Security System ….. 56 Section 5.10 Summary of Instructions and Concepts ………… 57 Chapter 6 Fundamental ESP Techniques ……………………………. 59 Section 6.0 Chapter Summary ………………………………… 59 Section 6.1 Introduction ………………………………………. 59 Section 6.2 Software Readability …………………………… 59 Section 6.3 Software Maintainability …………………………. 60 2 Chapter 6 Section 6.4 Software Fundamentals ………………………….. 60 Section 6.5 The Background Routine ………………………… 61 Section 6.6 The Watch-Dog Timer …………………………… 61 Section 6.7 Event-Driven Software …………………………... 62 Section 6.8 Interrupts …………………………………………. 65 Section 6.9 Slow Inputs and Outputs …………………………. 65 Section 6.10 Software Time Measurement …………………… 66 Section 6.11 Hashing …………………………………………. 67 Section 6.12 Waveform Encoding ……………………………. 68 Section 6.13 Waveform Decoding …………………………… 71 Section 6.14 RAM, ROM, and Time Tradeoffs ……………… 75 Section 6.15 ROM States ……………………………………... 75 Section 6.16 Limitations of C/C++ …………………………… 76 Chapter 7 Advanced ESP ……………………………………………. 78 Section 7.0 Chapter Summary ………………………………… 78 Section 7.1 Introduction ………………………………………. 78 Section 7.2 Sine Wave Generation …………………………….78 Section 7.3 Dual-Tone-Multi-Frequency (DTMF) Signaling …81 Section 7.4 Pulse-Width Modulation ………………………….82 Section 7.5 ADPCM Data Compression ………………………84 Section 7.6 Test Functions and System Ideas …………………87 Chapter 8 PIC Peripherals and Interrupts ……………………………91 Section 8.0 Chapter Summary ………………………………...91 Section 8.1 Overview of the PIC Peripherals …………………91 Section 8.2 Input/Output Ports ………………………………..93 Section 8.2.1 Port A ………………………………………….. 93 Section 8.2.2 Port B, Port C, Port D ………………………….. 95 Section 8.2.3 Port E ………………………………………….. 95 Section 8.3 Interrupts …………………………………………. 95 Section 8.4 ADC and Analog MUX ………………………….. 98 Section 8.5 Watch-Dog Timer ………………………………... 102 Section 8.6 Timer 0 …………………………………………… 103 Section 8.7 Timer 1 ………………………………………….. 105 Section 8.8 Timer 2 ………………………………………….. 106 Section 8.9 Capture Mode …………………………………… 107 Section 8.10 Compare Mode ………………………………… 109 Section 8.11 Pulse-Width Modulation (PWM) ……………… 111 Section 8.12 Parallel Slave Port ……………………………… 114 3 Chapter 8 Section 8.13 EEPROM Data Memory ………………………… 116 Section 8.14 FLASH Program Memory ………………………. 117 Section 8.15 FLASH Code & Data EEPROM Protection ……. 118 Section 8.16 The CONFIGURATION Word ………………… 119 Section 8.17 Sleep Modes & Reset Modes …………………… 120 Chapter 9 PIC Peripherals, Serial Communications Ports ……………122 Section 9.0 Chapter Summary …………………………………122 Section 9.1 Introduction ……………………………………….122 Section 9.2 USART (Overview) ………………………………122 Section 9.2.1 USART (Asynchronous Mode, Full-Duplex) …..123 Section 9.2.2 USART (Synchronous, Master Mode) ………… 127 Section 9.2.3 USART (Synchronous, Slave Mode) ………….. 128 Section 9.3 Serial Peripheral Interface (Master Mode) ………. 128 Section 9.4 Serial Peripheral Interface (Slave Mode) …………132 Section 9.5 I2C System Overview …………………………….134 Section 9.5.1 I2C Slave Mode …………………………………137 Section 9.5.2 I2C Master Mode ………………………………. 139 Chapter 10 DSP Fundamentals ……………………………………… 147 Section 10.0 Chapter Summary ………………………………. 147 Section 10.1 Introduction …………………………………….. 147 Section 10.2 An Example: A Low-Pass Filter ……………….. 148 Section 10.3 An Example: A High-Pass Filter ………………. 148 Section 10.4 DSP Filters in General ………………………… 149 Section 10.5 Aliasing and the Nyquist Sampling Theorem ……149 Section 10.6 DSP Cookbook I: A Simple LPF/HPF …………. 151 Section 10.7 DSP Cookbook II: A Simple BPF ……………… 152 Section 10.8 DSP Cookbook III: A Median Filter …………… 153 Section 10.9 DSP Example I: Standard DTMF Decoding …….154 Section 10.10 DSP Example II: Alternative DTMF Decoding .. 155 Section 10.11 DSP Application: Speech Compression ………… 159 Appendix A The PIC16F877 Instruction Set ………………………….. 163 Appendix B Useful C++ Programs for PIC ASM Applications ………. 180 Appendix C Special Function Registers (RAM Addresses & Bits) ……185 Appendix D PIC16F877 Register File Map ……………………………191 Appendix E PIC16F877 Pin Function Map ……………………………192 Appendix F Save/Restore Registers on Interrupt ……………………… 193 References ………………………………………………………………. 195 4 Preface This book is intended for use by Junior-level undergraduates, Senior-level undergraduates, and Graduate students in electrical engineering as well as practicing electrical engineers and hobbyists and seeks to provide a gentle introduction to embedded systems programming with the Microchip PIC16F877 microcontroller. After introducing the PIC16F877 and its programming, this book covers the fundamental techniques and advanced level techniques of embedded systems programming in a general sense. The general sense ESP techniques can be applied to any microcontroller. There is also an introduction to the fundamentals of digital signal processing (DSP) using the PIC16F877. I would like to thank Dr. Dan Simon of the Cleveland State University Electrical Engineering Department for his kind and valuable help and suggestions in the preparations for this book. I would also like to thank John R. Owerko and James R. Jackson, both of A.R.F Products, Inc., for their expertise in the security systems market. I owe them both a great debt for my knowledge of security systems and for expanding my knowledge of the techniques of embedded systems programming in general. Special thanks also go to Sister Renee Oliver who proofread the manuscript and offered many helpful suggestions. Thanks go to my friends Damian Poirier, Jim Strieter, Greg Glazer, Zarif Bastawros, Brian McGeever, Ted Seman, and Jim Chesebrough who offered many helpful suggestions. Any errors that remain in the text are mine and I will correct them in the next edition. Timothy D. Green November 2005 Cleveland, Ohio 5 List of Figures 2-1 uP Internal View Block Diagram 2-2 PIC16F877 Internal Block Diagram 3-1 Simple Hardware View (Ports Only) 3-2 Basic Hardware System Example 4-1 A Simple Security System 5-1 Twelve-Key Matrix Keypad 5-2 PIC Matrix Keypad Interface Circuit 5-3 Seven Segment LED Digit Display in Common Cathode and Common Anode Forms 5-4 Single LED Digit Drives for Common Cathode/Anode Forms 5-5a Multiplexed LED Digit Drives for Common Cathode Form 5-5b Multiplexed LED Digit Drives for Common Anode Form 5-6 Illustration of Indirect RAM Addressing 5-7 Diagram of RLF and RRF Instructions 6-1 “All Digital” Watch-Dog Timer Circuit 6-2 Event-Driven Push-Button Switch DeBouncing 6-3 Manchester Code Waveform 6-4 Decoding of Manchester Waveform 7-1 Gaussian Probability Density Function and a Set of Sampled Values 8-1 ADCON1 “Analog vs Digital” Selection Codes 8-2 PIC16F877 Interrupt Tree 9-1 Master Mode SPI Mode Timing 9-2 Serial-Out/Serial-In with the 74HC164 and 74HC165 9-3 Serial-Out/Serial-In with Gated Clock to Inhibit Serial Out 9-4 SPI Mode Timing (Slave Mode, CKE = 0) 9-5 SPI Mode Timing (Slave Mode, CKE = 1) 10-1 Example of Aliasing When Sampling an Analog Signal 10-2 “Slow-to-Fast” Mode Speech Compression Process 10-3 “Fast-to-Slow” Mode Speech Compression Process Appendix A Figure: Diagram of RLF and RRF Instructions 6 Abbreviations and Acronyms ABS = Absolute Value ACCUM = Accumulator ADC = Analog-to-Digital Converter ADPCM = Adaptive Differential Pulse Code Modulation ALU = Arithmetic Logic Unit Arccos = Arc-Cosine ASCII = American Standard Code for Information Interchange ATM = Automatic Teller Machine BOR = Brown Out Reset BPF = Band Pass Filter CK = Clock Cos = Cosine CPU = Central Processing Unit D = Data DAC = Digital-to-Analog Converter dB = Decibels DC = Direct Current DDS = Direct Digital Synthesis DIP = Dual Inline Package DPSK = Differential Phase Shift Keying DSP = Digital Signal Processing DTMF = Dual Tone Multi-Frequency EEPROM = Electrically Erasable Programmable Read Only Memory EMC = Electro-Magnetic Compatibility EMI = Electro-Magnetic Interference EPROM = Erasable Programmable Read Only Memory ESP = Embedded Systems Programming Fmax = Maximum Frequency Fosc = Oscillator
Recommended publications
  • E0C88 CORE CPU MANUAL NOTICE No Part of This Material May Be Reproduced Or Duplicated in Any Form Or by Any Means Without the Written Permission of Seiko Epson
    MF658-04 CMOS 8-BIT SINGLE CHIP MICROCOMPUTER E0C88 Family E0C88 CORE CPU MANUAL NOTICE No part of this material may be reproduced or duplicated in any form or by any means without the written permission of Seiko Epson. Seiko Epson reserves the right to make changes to this material without notice. Seiko Epson does not assume any liability of any kind arising out of any inaccuracies contained in this material or due to its application or use in any product or circuit and, further, there is no representation that this material is applicable to products requiring high level reliability, such as medical products. Moreover, no license to any intellectual property rights is granted by implication or otherwise, and there is no representation or warranty that anything made in accordance with this material will be free from any patent or copyright infringement of a third party. This material or portions thereof may contain technology or the subject relating to strategic products under the control of the Foreign Exchange and Foreign Trade Control Law of Japan and may require an export license from the Ministry of International Trade and Industry or other approval from another government agency. Please note that "E0C" is the new name for the old product "SMC". If "SMC" appears in other manuals understand that it now reads "E0C". © SEIKO EPSON CORPORATION 1999 All rights reserved. CONTENTS E0C88 Core CPU Manual PREFACE This manual explains the architecture, operation and instruction of the core CPU E0C88 of the CMOS 8-bit single chip microcomputer E0C88 Family. Also, since the memory configuration and the peripheral circuit configuration is different for each device of the E0C88 Family, you should refer to the respective manuals for specific details other than the basic functions.
    [Show full text]
  • Visualage for Smalltalk Handbook Volume 2: Features
    SG24-2219-00 VisualAge for Smalltalk Handbook Volume 2: Features September 1997 SG24-2219-00 International Technical Support Organization VisualAge for Smalltalk Handbook Volume 2: Features September 1997 IBM Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix A, “Special Notices.” First Edition (September 1997) This edition applies to VisualAge for Smalltalk, Versions 2, 3, and 4, for use with OS/2, AIX, and Microsoft Windows 95/NT. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. QXXE Building 80-E2 650 Harry Road San Jose, California 95120-6099 When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1997. All rights reserved. Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp. Contents Preface . xiii How This Redbook Is Organized ....................... xiv ITSO on the Internet ................................ xv VisualAge Support on CompuServe ..................... xvii About the Authors ................................ xvii Acknowledgments . xviii Comments Welcome . xix Chapter 1. AS/400 Connection . 1 Multiple Programs with a Single Remote Procedure Call ......... 1 RPC Part Sets Commit Boundary ........................ 1 Connection Problem with V3R1 ......................... 2 AS/400 Communication Error .......................... 2 Strange Characters on Log-on Window .................... 3 Quick Form from AS/400 Record Classes ................... 3 Communication . 4 Read Next/Previous . 4 SQL Statements . 5 Data Queues and Records ............................ 6 ODBC Requirements .
    [Show full text]
  • Programming-8Bit-PIC
    Foreword Embedded microcontrollers are everywhere today. In the average household you will find them far beyond the obvious places like cell phones, calculators, and MP3 players. Hardly any new appliance arrives in the home without at least one controller and, most likely, there will be several—one microcontroller for the user interface (buttons and display), another to control the motor, and perhaps even an overall system manager. This applies whether the appliance in question is a washing machine, garage door opener, curling iron, or toothbrush. If the product uses a rechargeable battery, modern high density battery chemistries require intelligent chargers. A decade ago, there were significant barriers to learning how to use microcontrollers. The cheapest programmer was about a hundred dollars and application development required both erasable windowed parts—which cost about ten times the price of the one time programmable (OTP) version—and a UV Eraser to erase the windowed part. Debugging tools were the realm of professionals alone. Now most microcontrollers use Flash-based program memory that is electrically erasable. This means the device can be reprogrammed in the circuit—no UV eraser required and no special packages needed for development. The total cost to get started today is about twenty-five dollars which buys a PICkit™ 2 Starter Kit, providing programming and debugging for many Microchip Technology Inc. MCUs. Microchip Technology has always offered a free Integrated Development Environment (IDE) including an assembler and a simulator. It has never been less expensive to get started with embedded microcontrollers than it is today. While MPLAB® includes the assembler for free, assembly code is more cumbersome to write, in the first place, and also more difficult to maintain.
    [Show full text]
  • Application Description PROCONTROL P 87TS01-E/R1313 Coupling Module
    Application Description PROCONTROL P Communication Coupling Module Time Master Publication No. D KWL 6316 96 E, Edition 10/96 Replacing D KWL 6316 96 E, Edition 05/96 87TS01-E/R1313 Application Every 59th second, a DCF77 time receiver coupled to the 87TS01-E/ R1313 module through an RS232c interface, conĆ forming to the prescribed time data format and transfer protoĆ Within the PROCONTROL system, module 87TS01-E/R1313col, sends the complete time telegram of the following full minĆ functions as a master clock which is set by a radioute clock and, (over in the 60th second, sends a synchronization characĆ a serial interface; reception is from the DCF77 timeter. transmitĆ This synchronization character is evaluated, and the interĆ ter), and which needs to be synchronized. The timenal received clock in module 87TS01-E/R1313 is synchronized. from the radio clock is made available to the entire PROCONĆ TROL system and is used as system time. It isThe transmitted master clock follows a 5-msec-rhythm and is synchroĆ cyclically in the form of time telegrams. nized to the DCF77 time receiver every 60 sec. Disturbance signals are generated if the time receiver or the internal clock The time telegrams containing the system time mayshould be reĆ fail. If synchronization takes place every 60 sec, the ceived and processed by modules specifically designedmaster for clock tends to go slow by < 5 msec. In the event of a this purpose. failure of the time receiver, the typical inaccuracy of the internal master clock is 3.4 sec/24 hrs. If an inaccuracy of a maximum of ± 1 sec is detected, the master clock is immediately switched over to the time received from the DCF77 time receiver.
    [Show full text]
  • Nintendo Wii Software
    Nintendo wii software A previous update, ( U) introduced the ability to transfer your data from one Wii U console to another. You can transfer save data for Wii U software, Mii. The Wii U video game console's built-in software lets you watch movies and have fun right out of the box. BTW, why does it sound like you guys are crying about me installing homebrew software on my Wii console? I am just wondering because it seems a few of you. The Nintendo Wii was introduced in and, since then, over pay for any of this software, which is provided free of charge to everyone. Perform to Popular Chart-Topping Tunes - Sing up to 30 top hits from Season 1; Gleek Out to Never-Before-Seen Clips from the Show – Perform to video. a wiki dedicated to homebrew on the Nintendo Wii. We have 1, articles. Install the Homebrew Channel on your Wii console by following the homebrew setup tutorial. Browse the Homebrew, Wii hardware, Wii software, Development. The Wii was not designed by Nintendo to support homebrew. There is no guarantee that using homebrew software will not harm your Wii. A crazy software issue has come up. It's been around 10 months since the wii u was turned on at all. Now that we have, it boots up fine and you. Thus, we developed a balance assessment software using the Nintendo Wii Balance Board, investigated its reliability and validity, and. In Q1, Nintendo DS software sales were million, up million units Wii software sales reached million units, a million.
    [Show full text]
  • Also Includes Slides and Contents From
    The Compilation Toolchain Cross-Compilation for Embedded Systems Prof. Andrea Marongiu ([email protected]) Toolchain The toolchain is a set of development tools used in association with source code or binaries generated from the source code • Enables development in a programming language (e.g., C/C++) • It is used for a lot of operations such as a) Compilation b) Preparing Libraries Most common toolchain is the c) Reading a binary file (or part of it) GNU toolchain which is part of d) Debugging the GNU project • Normally it contains a) Compiler : Generate object files from source code files b) Linker: Link object files together to build a binary file c) Library Archiver: To group a set of object files into a library file d) Debugger: To debug the binary file while running e) And other tools The GNU Toolchain GNU (GNU’s Not Unix) The GNU toolchain has played a vital role in the development of the Linux kernel, BSD, and software for embedded systems. The GNU project produced a set of programming tools. Parts of the toolchain we will use are: -gcc: (GNU Compiler Collection): suite of compilers for many programming languages -binutils: Suite of tools including linker (ld), assembler (gas) -gdb: Code debugging tool -libc: Subset of standard C library (assuming a C compiler). -bash: free Unix shell (Bourne-again shell). Default shell on GNU/Linux systems and Mac OSX. Also ported to Microsoft Windows. -make: automation tool for compilation and build Program development tools The process of converting source code to an executable binary image requires several steps, each with its own tool.
    [Show full text]
  • GPS170PEX User Manual
    Technical Information Operating Instructions GPS170PEX Contact Information Meinberg Funkuhren GmbH & Co. KG Lange Wand 9 D-31812 Bad Pyrmont Phone: ++49 52 81 - 9309-0 Fax: ++49 52 81 - 9309-30 Internet: http://www.meinberg.de Email: [email protected] September 16, 2009 Table of Contents Contact Information............................................................................. 2 Content of the USB stick ..................................................................... 5 General information............................................................................. 6 PCI Express (PCIe) .............................................................................. 7 Block diagram GPS170PEX ................................................................ 8 GPS170PEX features ........................................................................... 9 Time zone and daylight saving .................................................. 9 Asynchronous serial ports ........................................................ 10 Time capture inputs.................................................................. 10 Pulse and frequency outputs .................................................... 10 DCF77 emulation ..................................................................... 12 Connectors and LEDs in the rear slot cover ...................................... 13 Installing the GPS170PEX in your computer.................................... 14 Configuring the 9 pin connector .............................................. 14 Mounting the
    [Show full text]
  • Cobol Pic Clause Example
    Cobol Pic Clause Example Albuminous and sonsie Scarface never apotheosising nae when Nealon mischarges his hogs. Unlawful Ingmar clips contiguously and super, she revering her cookers benefit symmetrically. Trifoliate Chaim sometimes circularize his breaches see and dilly-dallies so dichotomously! Quetelet index file exactly the coefficient is not confuse the input procedure division resets the rerun in another accept message or paragraphs that? Early cobol example of examples are evaluated one having to pic x when clause is considered useless instructions and date formats will be made quickly than one. After a group item is never reserved words cannot be written under different format you can it occupies in an operational sign printed documentation is suppressed. Because they may be a sample program by requesting a short paragraph in each source item can be greater detail report item is impossible in the records. Exit program using pic n it will be only, or more sections into a pic clause is executed as shown in a file to. Duplicate keys or fetch a call to_char with input call to describe data description during execution of examples of this area b it! We delimit by cobol example illustrates this server outputs data division sections having one. Basic cobol example. The individual file is provided for pic x variables being defined by use of messages. The cobol picture indicates a cobol api to cobol pic clause example. This call function is defined width of the usage is to a table can you explicitly searched last sentence and pic clause scales as steps. No cobol example with clause indicates the pic clause specifies that truncation or.
    [Show full text]
  • Embedded Linux Systems with the Yocto Project™
    OPEN SOURCE SOFTWARE DEVELOPMENT SERIES Embedded Linux Systems with the Yocto Project" FREE SAMPLE CHAPTER SHARE WITH OTHERS �f, � � � � Embedded Linux Systems with the Yocto ProjectTM This page intentionally left blank Embedded Linux Systems with the Yocto ProjectTM Rudolf J. Streif Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City São Paulo • Sidney • Hong Kong • Seoul • Singapore • Taipei • Tokyo Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales depart- ment at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected]. For questions about sales outside the U.S., please contact [email protected]. Visit us on the Web: informit.com Cataloging-in-Publication Data is on file with the Library of Congress.
    [Show full text]
  • Design Languages for Embedded Systems
    Design Languages for Embedded Systems Stephen A. Edwards Columbia University, New York [email protected] May, 2003 Abstract ward hardware simulation. VHDL’s primitive are assign- ments such as a = b + c or procedural code. Verilog adds Embedded systems are application-specific computers that transistor and logic gate primitives, and allows new ones to interact with the physical world. Each has a diverse set be defined with truth tables. of tasks to perform, and although a very flexible language might be able to handle all of them, instead a variety of Both languages allow concurrent processes to be de- problem-domain-specific languages have evolved that are scribed procedurally. Such processes sleep until awak- easier to write, analyze, and compile. ened by an event that causes them to run, read and write variables, and suspend. Processes may wait for a pe- This paper surveys some of the more important lan- riod of time (e.g., #10 in Verilog, wait for 10ns in guages, introducing their central ideas quickly without go- VHDL), a value change (@(a or b), wait on a,b), ing into detail. A small example of each is included. or an event (@(posedge clk), wait on clk un- 1 Introduction til clk='1'). An embedded system is a computer masquerading as a non- VHDL communication is more disciplined and flexible. computer that must perform a small set of tasks cheaply and Verilog communicates through wires or regs: shared mem- efficiently. A typical system might have communication, ory locations that can cause race conditions. VHDL’s sig- signal processing, and user interface tasks to perform.
    [Show full text]
  • Computer Architecture and Assembly Language
    Computer Architecture and Assembly Language Gabriel Laskar EPITA 2015 License I Copyright c 2004-2005, ACU, Benoit Perrot I Copyright c 2004-2008, Alexandre Becoulet I Copyright c 2009-2013, Nicolas Pouillon I Copyright c 2014, Joël Porquet I Copyright c 2015, Gabriel Laskar Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being just ‘‘Copying this document’’, no Front-Cover Texts, and no Back-Cover Texts. Introduction Part I Introduction Gabriel Laskar (EPITA) CAAL 2015 3 / 378 Introduction Problem definition 1: Introduction Problem definition Outline Gabriel Laskar (EPITA) CAAL 2015 4 / 378 Introduction Problem definition What are we trying to learn? Computer Architecture What is in the hardware? I A bit of history of computers, current machines I Concepts and conventions: processing, memory, communication, optimization How does a machine run code? I Program execution model I Memory mapping, OS support Gabriel Laskar (EPITA) CAAL 2015 5 / 378 Introduction Problem definition What are we trying to learn? Assembly Language How to “talk” with the machine directly? I Mechanisms involved I Assembly language structure and usage I Low-level assembly language features I C inline assembly Gabriel Laskar (EPITA) CAAL 2015 6 / 378 I Programmers I Wise managers Introduction Problem definition Who do I talk to? I System gurus I Low-level enthusiasts Gabriel Laskar (EPITA) CAAL
    [Show full text]
  • PIC Assembly Language for the Complete Beginner
    PIC Assembly Language for the Complete Beginner Michael A. Covington Artificial Intelligence Center The University of Georgia Athens, Georgia 30602-7415 http://www.ai.uga.edu/mc This article appeared in Electronics Now Magazine in 1999 and is reprinted here by permission. Some web addresses have been up- dated but the content has not; you will find that MPLAB, for instance, now looks somewhat different. You may print out this article for personal use but not for further pub- lication. Copyright c 1999 Gernsback Publications, Inc. Copyright c 1999, 2004 Michael A. Covington. These days, the field of electronics is divided into “haves” and “have- nots” – people who can program microcontrollers and people who can’t. If you’re one of the “have-nots,” this article is for you. 1 Microcontrollers are one-chip computers designed to control other equip- ment, and almost all electronic equipment now uses them. The average American home now contains about 100 computers, almost all of which are microcontrollers hidden within appliances, clocks, thermostats, and even automobile engines. Although some microcontrollers can be programmed in C or BASIC, you need assembly language to get the best results with the least expensive micros. The reason is that assembly language lets you specify the exact instructions that the CPU will follow; you can control exactly how much time and memory each step of the program will take. On a tiny computer, this can be important. What’s more, if you’re not already an experienced programmer, you may well find that assembly language is simpler than BASIC or C.
    [Show full text]