5-2-1 PIC microcontroller. Learning objectives To aid revision, areas that are examinable are identified by a vertical line in the left margin. Where.

Slides:



Advertisements
Similar presentations
Interrupts How to do 2 things at the same time. Need for interrupts Computers often have to deal with asynchronous events. That is to say events that.
Advertisements

Computer Memory and Data Transfer
Electronics Design Lab TUTORIAL PIC Microcontrollers Francesco Tenore 2/10/2006.
Applications of PICs Advantages/disadvantages Digital and analogue control Loops, sub-routines, scanning, counting and feedback Interrupts Problems with.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Khaled A. Al-Utaibi  Computers are Every Where  What is Computer Engineering?  Design Levels  Computer Engineering Fields  What.
Engr. M.K.Debnath1 Microcontroller and PLC Eng. ISRAFIL KHAN. DIPLOMA IN ELECTRONIC.
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
Prof. Jorge A. Ramón Introducción a Microcontroladores.
Hardware Basics: Inside the Box 2  2001 Prentice Hall2.2 Chapter Outline “There is no invention – only discovery.” Thomas J. Watson, Sr. What Computers.
Introduction to Microprocessors Number Systems and Conversions No /6/00 Chapter 1: Introduction to 68HC11 The 68HC11 Microcontroller.
Recap – Our First Computer WR System Bus 8 ALU Carry output A B S C OUT F 8 8 To registers’ input/output and clock inputs Sequence of control signal combinations.
Railway Foundation Electronic, Electrical and Processor Engineering.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
Microcontroller Architecture— PIC18F Family
Railway Foundation Electronic, Electrical and Processor Engineering.
Basic Computer Organization CH-4 Richard Gomez 6/14/01 Computer Science Quote: John Von Neumann If people do not believe that mathematics is simple, it.
5.1 Chaper 4 Central Processing Unit Foundations of Computer Science  Cengage Learning.
CPU Describe the purpose of the CPU
Chapter 17 Microprocessor Fundamentals William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
1 © Unitec New Zealand Embedded Hardware ETEC 6416 Date: - 10 Aug,2011.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Computer Organization
MICROCONTROLLERS. What is a microcontroller? A microcontroller is a nifty little gadget that houses a microprocessor, ROM (Read Only Memory), RAM (Random.
Lesson 3 — How a Computer Processes Data
Higher Computing Computer Systems S. McCrossan 1 Higher Grade Computing Studies 2. Computer Structure Computer Structure The traditional diagram of a computer...
Lecture#14. Last Lecture Summary Memory Address, size What memory stores OS, Application programs, Data, Instructions Types of Memory Non Volatile and.
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
Chapter Two Hardware Basics: Inside the Box. ©1999 Addison Wesley Longman2.2 Chapter Outline What Computers Do A Bit About Bits The Computer’s Core: CPU.
Training program: Mechanic - electrotechnician Program name: Digital processing - microprocessors III. class Microcontrollers Elaborated by: Vlastimil.
Lesson 3 — How a Computer Processes Data Unit 1 — Computer Basics.
Basic of Programming Language Skill Area Computer System Computer Program Programming Language Programmer Translators.
Computer Organization - 1. INPUT PROCESS OUTPUT List different input devices Compare the use of voice recognition as opposed to the entry of data via.
SKILL AREA: 1.2 MAIN ELEMENTS OF A PERSONAL COMPUTER.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
1 © Unitec New Zealand Interrupt Lecture 6 Date: - 20 Sept, 2011 Embedded Hardware ETEC 6416.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
MICROOCESSORS AND MICROCONTROLLER:
Interrupts  An interrupt is any service request that causes the CPU to stop its current execution stream and to execute an instruction stream that services.
Identifying Hardware Components in a Computer (continued) Clock Speed (continued) The computer has a system clock that generates a regular electronic beat.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
Overview von Neumann Architecture Computer component Computer function
Review of Computer System Organization. Computer Startup For a computer to start running when it is first powered up, it needs to execute an initial program.
IT3002 Computer Architecture
Department of Electronic & Electrical Engineering Template program. Input / Output (IO) ● Template program. ● Introduction to IO ● Setting up for IO ●
Computer operation is of how the different parts of a computer system work together to perform a task.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Department of Electronic & Electrical Engineering Introduction to microcontrollers A microcontroller is a small computer on a single integrated circuit.
Department of Electronic & Electrical Engineering Lecture 2. PIC16F84A Architecture / Instructions Memory. Program/Data (Harvard) File Registers (Data).
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
Von Neumann Machines. 3 The Von Neumann Architecture Model for designing and building computers, based on the following three characteristics: 1)The.
HOME AUTOMATION USING PC DONE BY RAJESHKUMAR S SRI HARSHA D.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
I/O PORTS. General purpose I/O pins can be considered the simplest of peripherals. They allow the PICmicro™ to monitor and control other devices. To add.
ET5 Specimen paper model answers.. S1 110 S2 001 S3 010 S4 000 S5 011 S6 101 S7 111.
GCSE Computer Science - Revision
Computer Systems Nat 4/5 Computing Science Computer Structure:
CPU Lesson 2.
GCSE Computing - The CPU
Computer Organization and Machine Language Programming CPTG 245
PROGRAMMABLE LOGIC CONTROLLERS SINGLE CHIP COMPUTER
Microprocessor and Microcontroller Fundamentals
Computing Systems Organization
Introduction to Microprocessors and Microcontrollers
Components of a CPU AS Computing - F451.
Chapter 5 Computer Organization
GCSE Computing - The CPU
Presentation transcript:

5-2-1 PIC microcontroller

Learning objectives

To aid revision, areas that are examinable are identified by a vertical line in the left margin. Where there is no vertical line, the notes are aimed only at improving understanding.

Programs and instructions A microprocessor processes digital data, following a sequence of instructions given in a program. The program is an instruction/data sandwich. The basic structure is: Instruction – do ‘this’ with the following data Data Instruction – now do ‘this’ with the next item of data Data and so on... The microprocessor is designed to process data in the form of binary numbers. It ‘understands’ a limited number of instructions, which it recognises because each is given a unique binary number.

The same idea can be used in some restaurants to order a meal: “I’ll have a number 45, followed by a number 19 with a number 68 to finish, please.” This works very efficiently, because the chef has a recipe to follow for each of the numbered items on the menu. In reality, programmers rarely write the program as a list of binary numbered instructions and data. Instead they use a mnemonic for each instruction – a word or abbreviation that suggests what the instruction does, for example goto, clrf (clear file) etc.

Programming languages In the world of microprocessors, there are a number of programming languages. Like all languages, these consist of a vocabulary (the mnemonics) and syntax (the ‘grammar’ used to link the mnemonics and data together to build a program of instructions.) A program will work only if the vocabulary and syntax are totally error-free.

A complication – PIC microcontrollers are an extensive and important group of microcontrollers, present in a wide range of devices from DVD players to engine management systems. There are a number of ‘dialects’ of their programming language. In particular, MPASM and TASM are common versions used to write programs for PICs. The instruction set is the same, but the syntax has minor differences, (rather like the versions of the English language spoken by Americans and by British.) For the module test, you need to be able to interpret code given in MPASM. In questions where you write the code yourself, it does not matter whether you use MPASM or TASM.

Types of memory The program and the data are stored in electronic memory. Items like the instruction decoder are stored during manufacture in permanent memory, called ROM (read-only memory.) Later, the user stores his/her program in volatile memory, called RAM (read-and-write memory). The contents of volatile memory are lost when the power is turned off. There is a third type of memory, mid-way between ROM and RAM. With this type, the user can write information into it, but the contents are retained even when the power is turned off. There are a number of ways to implement this. The PIC chips which we use have this type of memory, known as EEPROM (electrically erasable programmable read-only memory.)

Ports Microprocessors control real world devices such as motors, heaters and lights. They monitor external conditions like temperature, speed and light intensity. They must have the means to input data from, and output data to, the outside world. This is done through electronic sub-systems called ports. A subsystem which imports data from the outside world to the microprocessor is called an input port. An output port sends data from the microprocessor to the outside world.

Microcontrollers vs microprocessors As the course deals with the micro-controller then it is left to the student to examine these differences for themselves as a matter of interest. A micro-controller requires the same components as a microprocessor, CPU, clock, memory and ports, but they are all housed in a single IC. It is not a replacement for a microprocessor system; it just does a different job. It has less memory than most microprocessor systems, and the processor usually runs more slowly. However, as a single chip solution, it is usually smaller, cheaper and more compact.

Pin 6 will be of particular interest to us later. As well as serving as the least significant bit of PORT B, it can also be used to trigger an external hardware interrupt. We will look at this in more detail later in these notes.

For information

Memory Organisation In the PIC microcontroller, program instructions and data are stored in separate areas of memory. Program instructions

The structure of the data area of RAM is shown in the table. Don’t worry about the names of these registers. We go into more detail for some of them later. Notice that some SFRs, such as the STATUS register and INTCON register, appear in both banks and can be accessed from either Bank 0 or Bank 1.

The lines that begin with a ‘;’ are known as remarks. The semicolon tells the system to ignore them, as they are not instructions, but merely comments that help humans to keep up with what is going on. Notice that the important lines are the ones that contain the equate (equ) command. These do not start with a semicolon!

Architecture of the PIC microcontroller Two “normal” forms of architecture are used in modern microprocessors, Von Neumann and Harvard architecture: For the purpose of the examination you will be examined on the Harvard Architecture.

Solutions to exam questions 1 Vss 0v

b) movlw b’ ’ ; move this binary value into the working register movwf INTCON ; move the contents in the working register into the intcon register c)04 goto inter d)bsf STATUS, RPO ; select bank 1 e)movlw b’ 11111’ ; move this binary number into the working register movwf TRISA ; move this number from the working register to TRISA movlw b’ ’ ; move this binary number into the working register movwf TRISB ; move this number from the working register to TRISB bcf STATUS, RPO; select bank 0

e)i) Polling switches wastes processor time by checking for something that happens only rarely. It is important that the processor responds instantly when the switch is pressed rather than for the relevant section of the program to occur.

Inter movwf workstore ; protects the working register Loop bsf PORTB,1 ; switches on the buzzer bsf PORTB,0 ; switches on the led call quart ; led stays on for 0.25 seconds, period of 2Hz bcf PORTB,0 ; switches led off call quart ; led goes off for 0.25 seconds btfss PORTA,0 ; test reset switch, if bit 0 is set skip next instruction, if not set continue with loop goto loop ; if bit 0 of PORTa not set continue with loop bct PORTB, 1 ; switch off buzzer movf workstore,0 ; restore working register rectfie ; return from interrupt routine

Cycle frequency2HZ 0.25s 0.25s