Rodolfo Rodriguez Kevin Zhang MJ Gellada

Slides:



Advertisements
Similar presentations
Instruction formats for the PIC series. ROM encoding Instructions are encoded in binary in ROM. The instructions are fixed format, each occupying 14 bits.
Advertisements

Electronics Design Lab TUTORIAL PIC Microcontrollers Francesco Tenore 2/10/2006.
Microcontroller – PIC – 4 PIC types PIC architecture
Prof. Jorge A. Ramón Introducción a Microcontroladores.
Microcontrollers Lecture L12.2 Section Microcontrollers Microcontrollers vs. Microprocessors Two standard architectures PIC microcontroller 68HC12.
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 26: PIC microcontroller intro.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
Railway Foundation Electronic, Electrical and Processor Engineering.
ASPPRATECH.
Microcontroller based system design
Programming 8-bit PIC Microcontrollers in C Martin Bates Elsevier 2008.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Instruction Set.
Micro controllers A self-contained system in which a processor, support, memory, and input/output (I/O) are all contained in a single package.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
9/20/6Lecture 21 -PIC Architecture1 PIC Architecture Programmers Model and Instruction Set.
Camera Interfacing using ARM7
PIC microcontrollers. PIC microcontrollers come in a wide range of packages from small chips with only 8 pins and 512 words of memory all the way up to.
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.
Two’s Complement Number wheel for 4 bit numbers
MICROCONTROLLERS. What is a microcontroller? A microcontroller is a nifty little gadget that houses a microprocessor, ROM (Read Only Memory), RAM (Random.
NetBurner MOD 5282 Network Development Kit MCF 5282 Integrated ColdFire 32 bit Microcontoller 2 DB-9 connectors for serial I/O supports: RS-232, RS-485,
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
4th MODULE.
Prepared by Eng. Musa Alyaman1 Chapter Seven Chapter Seven PIC16F87x.
PIC18F Programming Model and Instruction Set
Lecture – 4 PIC18 Family Instruction Set 1. Outline Literal instructions. Bit-oriented instructions. Byte-oriented instructions. Program control instructions.
PIC Processor Design CPE 428/528 April 29, 2002 Dr. Milenkovic Presented by: David Fatzer Le Pitts William Cruger Donn Hall.
MICROCONTROLLER SYSTEMS Part 1. Figure 1.1Elements of a digital controller CPU Central Processing Unit Input Peripherals Output Peripherals ROM Read Only.
Chapter 2 Introducing the PIC Mid-Range Family and the 16F84A The aims of this chapter are to introduce: The PIC mid-range family, in overview The overall.
ATtiny23131 A SEMINAR ON AVR MICROCONTROLLER ATtiny2313.
 Mini-Computer  Microprocessor  The Brains  Arithmetic Logic Unit (ALU)  Control Unit  Program/ Data Storage  Peripherals (Input/Output) Low-Cost.
EEE237 Introduction to Microprocessors Week x. SFRs.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
Lecture 7: Overview Microprocessors / microcontrollers.
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.
PIC12F629/675. “Wide variety” 8-84 pin RISC core, 12/14/16bit program word USART/AUSART, I 2 C, ADC, ICSP, ICD OTP/UV EPROM/FLASH/ROM Families: PIC12,
Chapter Microcontroller
Microcontrollers A Practical Approach Ernesto Arroyo
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
Components of a typical full-featured microcontroller.
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.
A Quick Start Guide to PIC16F877 microcontroller And Microchip Development Environment A Quick Start Guide to PIC16F877 microcontroller And Microchip Development.
CEng3361/18 CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT Spring 2007 Recitation 01.
Microprocessor Systems Design I
Embedded Hardware.
PROGRAMMABLE LOGIC CONTROLLERS SINGLE CHIP COMPUTER
Prof. Ahmad Abu-El-Haija
Microprocessor Systems Design I
Microprocessor Systems Design I
Micro-processor vs. Micro-controller
Microprocessor Systems Design I
Microprocessor Systems Design I
C. K. PITHAWALA COLLEGE OF ENGINEERING AND TECHNOLOGY
Microprocessor Systems Design I
Microprocessor Systems Design I
PIC – ch. 2b Md. Atiqur Rahman Ahad.
PIC 16F877.
Microprocessor Systems Design I
Subject Name: Microcontroller Subject Code: 10ES42
Introduction to Microprocessors and Microcontrollers
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
EECE.3170 Microprocessor Systems Design I
Presentation transcript:

Rodolfo Rodriguez Kevin Zhang MJ Gellada PIC MICROCONTROLLER Rodolfo Rodriguez Kevin Zhang MJ Gellada

Overview Microcontroller and Architecture Basics Variants among families ISA Programming overview Hardware interface/Developmental boards

Description PIC – “Peripheral Interface Controller” Made by Microchip Technology Most popular by industry developers and hobbyists Low cost (cents to dollars) Availability Extensive application notes Serial programming

v http://www.microchip.com/stellent/images/mchpsiteimages/en537986.jpg

8-bit Core Architecture Harvard (separate code and data space) RISC One accumulator W Register Small addressable data space (256 bytes) Banking RAM PC, special purpose registers http://www.microchip.com/_images/BaselineArch_large.jpg

Advantages & Limitations to 8-bit Architecture Small ISA to learn Built in oscillator with selectable speeds Development made easy Inexpensive Device variants Wide range of interfaces (I2C, SPI, etc.) One accumulator Bank switching Hardware call stack unaddressable (no multi-tasking)

16-bit and 32-bit Architecture More working registers No bank switching Assignable interrupt vector table More flash memory Cache (32-bit architecture)

Application Notes Very extensive Description of documentation 16758 items Description of documentation PDF documenation Source code http://www.microchip.com/TechDoc.aspx?type=appnotes http://www.microchip.com/TechDoc.aspx?type=appnotes

8-bit architecture Pin Count 6-40 8-64 18-100 Interrupts No Baseline Architecture Mid-Range Architecture Enhanced Mid-Range Architecture PIC18 Architecture Pin Count 6-40 8-64 18-100 Interrupts No Single interrupt capability Single interrupt capability with hardware context save Multiple interrupt capability with hardware context save Performance 5 MIPS 8 MIPS Up to 16 MIPS Instructions 33, 12-bit 35, 14-bit 49, 14-bit 83, 16-bit Program Memory Up to 3 KB Up to 14 KB Up to 28 KB Up to 128 KB Data Memory Up to 138 Bytes Up to 368 Bytes Up to 1.5 KB Up to 4 KB Features Comparator 8-bit ADC Internal Oscillator In addition to Baseline: SPI/I²C™ UART PWMs LCD 10-bit ADC Op Amp In addition to Mid-Range: Multiple Communication Peripherals Linear Programming Space PWMs with Independent Time Base In addition to Enhanced Mid-Range: 8x8 Hardware Multiplier CAN CTMU USB Ethernet 12-bit ADC Families PIC10, PIC12, PIC16 PIC12, PIC16 PIC12FXXX, PIC16F1XX PIC18 8-bit architecture

0 -> WDT, 1 -> TO, 0 -> PD PIC16 ISA: 35 Instructions, 14-bit INSTRUCTION DESCRIPTION OPERATION Data Transfer Instructions MOVLW k Move constant to W k -> w MOVWF f Move W to f W -> f MOVF f,d Move f to d f -> d CLRW Clear W 0 -> W CLRF f Clear f 0 -> f SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) Arithmetic-logic Instructions ADDLW k Add W and constant W+k -> W ADDWF f,d Add W and f W+f -> d SUBLW k Subtract W from constant k-W -> W SUBWF f,d Subtract W from f f-W -> d ANDLW k Logical AND with W with constant W AND k -> W ANDWF f,d Logical AND with W with f W AND f -> d IORLW k Logical OR with W with constant W OR k -> W IORWF f,d Logical OR with W with f W OR f -> d XORWF f,d Logical exclusive OR with W with constant W XOR k -> W XORLW k Logical exclusive OR with W with f W XOR f -> d INCF f,d Increment f by 1 f+1 -> f DECF f,d Decrement f by 1 f-1 -> f RLF f,d Rotate left f through CARRY bit RRF f,d Rotate right f through CARRY bit COMF f,d Complement f Bit-oriented Instructions BCF f,b Clear bit b in f 0 -> f(b) BSF f,b 1 -> f(b) Program Control Instructions BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 GOTO k Go to address k -> PC CALL k Call subroutine PC -> TOS, k -> PC RETURN Return from subroutine TOS -> PC RETLW k Return with constant in W k -> W, TOS -> PC RETFIE Return from interrupt TOS -> PC, 1 -> GIE Other instructions NOP No operation CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD Data Transfer Instructions INSTRUCTION DESCRIPTION OPERATION MOVLW k Move constant to W k -> w MOVWF f Move W to f W -> f MOVF f,d Move f to d f -> d CLRW Clear W 0 -> W CLRF f Clear f 0 -> f SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) PIC16 ISA W: Working register(Accumulator) Registers: Memory locations

0 -> WDT, 1 -> TO, 0 -> PD INSTRUCTION DESCRIPTION OPERATION Data Transfer Instructions MOVLW k Move constant to W k -> w MOVWF f Move W to f W -> f MOVF f,d Move f to d f -> d CLRW Clear W 0 -> W CLRF f Clear f 0 -> f SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) Arithmetic-logic Instructions ADDLW k Add W and constant W+k -> W ADDWF f,d Add W and f W+f -> d SUBLW k Subtract W from constant k-W -> W SUBWF f,d Subtract W from f f-W -> d ANDLW k Logical AND with W with constant W AND k -> W ANDWF f,d Logical AND with W with f W AND f -> d IORLW k Logical OR with W with constant W OR k -> W IORWF f,d Logical OR with W with f W OR f -> d XORWF f,d Logical exclusive OR with W with constant W XOR k -> W XORLW k Logical exclusive OR with W with f W XOR f -> d INCF f,d Increment f by 1 f+1 -> f DECF f,d Decrement f by 1 f-1 -> f RLF f,d Rotate left f through CARRY bit RRF f,d Rotate right f through CARRY bit COMF f,d Complement f Bit-oriented Instructions BCF f,b Clear bit b in f 0 -> f(b) BSF f,b 1 -> f(b) Program Control Instructions BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 GOTO k Go to address k -> PC CALL k Call subroutine PC -> TOS, k -> PC RETURN Return from subroutine TOS -> PC RETLW k Return with constant in W k -> W, TOS -> PC RETFIE Return from interrupt TOS -> PC, 1 -> GIE Other instructions NOP No operation CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD Arithmetic-logic Instructions (partial) ADDLW k Add W and constant W+k -> W ADDWF f,d Add W and f W+f -> d INCF f,d Increment f by 1 f+1 -> f DECF f,d Decrement f by 1 f-1 -> f RLF f,d Rotate left f through CARRY bit RRF f,d Rotate right f through CARRY bit COMF f,d Complement f f -> d PIC16 ISA SUBLW, SUBWF ANDLW, ANDWF IORLW, IORWF XORLW, XORWF

0 -> WDT, 1 -> TO, 0 -> PD INSTRUCTION DESCRIPTION OPERATION Data Transfer Instructions MOVLW k Move constant to W k -> w MOVWF f Move W to f W -> f MOVF f,d Move f to d f -> d CLRW Clear W 0 -> W CLRF f Clear f 0 -> f SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) Arithmetic-logic Instructions ADDLW k Add W and constant W+k -> W ADDWF f,d Add W and f W+f -> d SUBLW k Subtract W from constant k-W -> W SUBWF f,d Subtract W from f f-W -> d ANDLW k Logical AND with W with constant W AND k -> W ANDWF f,d Logical AND with W with f W AND f -> d IORLW k Logical OR with W with constant W OR k -> W IORWF f,d Logical OR with W with f W OR f -> d XORWF f,d Logical exclusive OR with W with constant W XOR k -> W XORLW k Logical exclusive OR with W with f W XOR f -> d INCF f,d Increment f by 1 f+1 -> f DECF f,d Decrement f by 1 f-1 -> f RLF f,d Rotate left f through CARRY bit RRF f,d Rotate right f through CARRY bit COMF f,d Complement f Bit-oriented Instructions BCF f,b Clear bit b in f 0 -> f(b) BSF f,b 1 -> f(b) Program Control Instructions BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 GOTO k Go to address k -> PC CALL k Call subroutine PC -> TOS, k -> PC RETURN Return from subroutine TOS -> PC RETLW k Return with constant in W k -> W, TOS -> PC RETFIE Return from interrupt TOS -> PC, 1 -> GIE Other instructions NOP No operation CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD Program Control Instructions BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 GOTO k Go to address k -> PC CALL k Call subroutine PC -> TOS, k -> PC RETURN Return from subroutine TOS -> PC RETLW k Return with constant in W k -> W, TOS -> PC RETFIE Return from interrupt TOS -> PC, 1 -> GIE PIC16 ISA

0 -> WDT, 1 -> TO, 0 -> PD INSTRUCTION DESCRIPTION OPERATION Data Transfer Instructions MOVLW k Move constant to W k -> w MOVWF f Move W to f W -> f MOVF f,d Move f to d f -> d CLRW Clear W 0 -> W CLRF f Clear f 0 -> f SWAPF f,d Swap nibbles in f f(7:4),(3:0) -> f(3:0),(7:4) Arithmetic-logic Instructions ADDLW k Add W and constant W+k -> W ADDWF f,d Add W and f W+f -> d SUBLW k Subtract W from constant k-W -> W SUBWF f,d Subtract W from f f-W -> d ANDLW k Logical AND with W with constant W AND k -> W ANDWF f,d Logical AND with W with f W AND f -> d IORLW k Logical OR with W with constant W OR k -> W IORWF f,d Logical OR with W with f W OR f -> d XORWF f,d Logical exclusive OR with W with constant W XOR k -> W XORLW k Logical exclusive OR with W with f W XOR f -> d INCF f,d Increment f by 1 f+1 -> f DECF f,d Decrement f by 1 f-1 -> f RLF f,d Rotate left f through CARRY bit RRF f,d Rotate right f through CARRY bit COMF f,d Complement f Bit-oriented Instructions BCF f,b Clear bit b in f 0 -> f(b) BSF f,b 1 -> f(b) Program Control Instructions BTFSC f,b Test bit b of f. Skip the following instruction if clear. Skip if f(b) = 0 BTFSS f,b Test bit b of f. Skip the following instruction if set. Skip if f(b) = 1 DECFSZ f,d Decrement f. Skip the following instruction if clear. f-1 -> d skip if Z = 1 INCFSZ f,d Increment f. Skip the following instruction if set. f+1 -> d skip if Z = 0 GOTO k Go to address k -> PC CALL k Call subroutine PC -> TOS, k -> PC RETURN Return from subroutine TOS -> PC RETLW k Return with constant in W k -> W, TOS -> PC RETFIE Return from interrupt TOS -> PC, 1 -> GIE Other instructions NOP No operation CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD Bit-oriented Instructions BCF f,b Clear bit b in f 0 -> f(b) BSF f,b Set bit b in f 1 -> f(b) PIC16 ISA Other instructions NOP No operation TOS -> PC, 1 -> GIE CLRWDT Clear watchdog timer 0 -> WDT, 1 -> TO, 1 -> PD SLEEP Go into sleep mode 0 -> WDT, 1 -> TO, 0 -> PD

PIC 16F887 layout Analog I/O PORTA I2C UART http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-world-of-microcontrollers/

Programming a PIC Microchip provides the free MPLAB: Compiler Assembler and linker Application development Hardware emulation Debugging C or assembly compatible Compiler Can be C-based or Basic A free one is the CCS C Compiler for PIC12/24/26/18 (not compatible with all PICS) or the HI-TECH PICC-Lit http://www.microchip.com/pagehandler/en-us/family/mplabx/

Programming Tools Basic based environments are available, but don’t offer the functionality of C Third party IDE’s might be preferred due to an enhanced software library or debugging tools http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002

Device Programmer Need device to store machine code into PIC’s memory (EEPROM or Flash) Can be external device, but ICSP is easier: Don’t have to remove chip from its circuit Provides interface between computer (USB) and PIC Specific to circuit (due to interconnect scheme and surrounding circuit) Communication protocol requires 5 signals The data is transferred using a two wire synchronous serial scheme, three more wires provide programming and chip power. The clock signal is always controlled by the programmer. http://en.wikipedia.org/wiki/PIC_microcontroller

Device Programmer Five Signals: Vpp (programming voltage) Vdd (power) Vss (ground) IC SPCLK (clock) IC SPDAT (data) Vpp - Programming mode voltage. This must be connected to the MCLR pin, or the Vpp pin of the optional ICSP port available on some large-pincount PICs. To put the PIC into programming mode, this line must be in a specified range that varies from PIC to PIC. For 5V PICs, this is always some amount above Vdd, and can be as high as 13.5V. The 3.3V only PICs like the 18FJ, 24H, and 33F series use a special signature to enter programming mode and Vpp is a digital signal that is either at ground or Vdd. There is no one Vpp voltage that is within the valid Vpp range of all PICs. In fact, the minimum required Vpp level for some PICs can damage other PICs. Vdd - This is the positive power input to the PIC. Some programmers require this to be provided by the circuit (circuit must be at least partially powered up), some programmers expect to drive this line themselves and require the circuit to be off, while others can be configured either way (like the Microchip ICD2). The Embed Inc programmers expect to drive the Vdd line themselves and require the target circuit to be off during programming. Vss - Negative power input to the PIC and the zero volts reference for the remaining signals. Voltages of the other signals are implicitly with respect to Vss. ICSPCLK - Clock line of the serial data interface. This line swings from GND to Vdd and is always driven by the programmer. Data is transferred on the falling edge. ICSPDAT - Serial data line. The serial interface is bi-directional, so this line can be driven by either the programmer or the PIC depending on the current operation. In either case this line swings from GND to Vdd. A bit is transferred on the falling edge of PGC. 1. Select device 2. Load HEX file 3. Program PIC http://en.wikipedia.org/wiki/PIC_microcontroller

Necessary Connections (PIC16F877A) PIC can be bread-boarded, with the following important connections: Power Ground Reset signal Crystal (oscillator) http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-world-of-microcontrollers/

LED example: code //LED example program written for //PIC programming tutorial. From //(http://seniord.ece.iastate.edu/dec0604/index_files/tutorialDec0604.pdf) //standard include files #include <stdlib.h> #include <pic.h> #include “delay.h” //main function void main() { PORTA = 0x00; //set RA0-RA5 low TRISA = 0x00; //set PORTA to output //superloop while(1) PORTA = ~PORTA; DelayMs(250); }

Development Boards Prepackaged boards come with a multitude of peripherals for development and debugging: Programmer User I/O: buttons, port pinouts, LED’s Displays: LCD and seven segment Power Serial connection interface

Easy PIC v7 from MikroElectronika USB Port Programmer PIC Power Supply LEDs and buttons Port Pinouts http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-world-of-microcontrollers/

Additional Peripherals Touch Screen ADC converter

Questions?

References http://www.microchip.com/ http://en.wikipedia.org/wiki/PIC_microcontroller http://www.mikroe.com/eng/chapters/view/10/chapter-9-instruction-set/ http://www.mikroe.com/eng/chapters/view/74/pic-basic-book-chapter-1-world-of-microcontrollers/ http://www.slideshare.net/element14/microchips-16bit-and-32bit-pic-mcus-7267006 http://www.ladyada.net/library/picvsavr.html