Top Banner

of 21

Intoduction to Microcontrollers - PIC

Feb 10, 2018

Download

Documents

Greg Mavhunga
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/22/2019 Intoduction to Microcontrollers - PIC

    1/21

    Introduction to Microcontrollers

    By Mr Gregory. K. Mavhunga

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    2/21

    Outline

    What is a microcontroller

    Why we use microcontrollers

    PIC microcontrollers Architecture

    Programming a PIC [16F628A]

    Example application

    Summary

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    3/21

    Microcontroller samples

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    4/21

    What is a microcontroller

    A microcontroller is a stand alone, self

    contained system with peripherals,

    memory, and a processor.

    Unlike microprocessor systems, which

    typically have RAM, ROM and other

    peripheral devices as standalone ICs or

    modules

    Contains all these items on one IC

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    5/21

    Advantages of microcontrollers

    Ease of use and accessibility

    Low cost with optimal performance

    Low power requirements, typical ofembedded devices

    Easily replaceable or re-purposed/ re-

    programmed

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    6/21

    Typical components of microcontroller

    Fig 01. Components of a microcontroller

    Address bus carries address from CPU to select a particular location in memory

    or I/O interface.

    Data bus carries data read/written between CPU & memory or I/O interface.

    Control buscarries timing signals such as READ & WRITE.

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    7/21

    Uses of microcontrollers

    Electrical appliances

    Automobile applications

    Toys Calculators

    Industrial process control

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    8/21

    PIC Microcontrollers

    Peripheral Interface Controller (PIC) wasoriginally designed by General Instruments

    In the late 1970s, GI introduced PIC 1650and 1655 RISC with 30 instructions.

    PIC was sold to Microchip Incorporated

    Features: low-cost, self-contained, 8-bit,

    Harvard structure, pipelined, RISC, singleaccumulator, with fixed reset and interruptvectors.

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    9/21

    PIC Architecture

    Fig 02 Havard architecture used

    In PIC MCus

    Address bus carries address from CPU to select a particular location in memory

    or I/O interface.

    Data bus carries data read/written between CPU & memory or I/O interface.

    Control buscarries timing signals such as READ & WRITE.

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    10/21

    PIC Families

    C implies CMOS technology; Complementary Metal Oxide Semiconductor

    F insert indicates incorporation of Flash memory technology

    Example: 16C84 was the first of its kind. It was later reissued as the 16F84,

    incorporating Flash memory technology. It was then reissued as 16F84A.

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    11/21

    Programming a PIC

    Components required

    - PIC, 16F628A , or any PIC microcontroller

    - MPLAB IDE (with C compiler

    HTC)- Programmer ( ICD2, PicKit 2, etc)

    Fig 6 Basic setup of programmer

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    12/21

    Programming languages

    Machine code prone to error and time

    consuming virtually non existent

    Assembly small code size, efficient memory

    use hence excellent good for time criticalroutines and applications

    High Level languages fast product

    development, easier to debug and maintain

    C

    Basic

    Pascal

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    13/21

    Programming example 16F628A

    35 instructions RISC

    RAM 224 bytes

    EEPROM

    128 bytes Flash 2048 words ( 2 bytes per word)

    Vcc +2.0V to +5V DC

    Output - +5V, 25mA current Cost - less than ZAR40

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    14/21

    PIC 16F628A

    Fig 4 Pin out of PIC 16F628A

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    15/21

    PIC 16F628A internal structure

    Fig 03 Simplified block

    diagram

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    16/21

    Fig 5 Program and data memory and peripherals of PIC 16F628A

    PIC 16F628A features

    35 instruction RISC controller

    Cheap and low power requirements Flash based as opposed to CMOS parts

    (reprogrammable multiple times)

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    17/21

    PIC 16F series assembly instruction set

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    18/21

    Basic Setup

    Fig 6 ICD2 and Pickit 2

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    19/21

    Circuit diagram

    Fig 7 PIC 16F887 blink LED example

    circuit

    Reset

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    20/21

    Sample program code

    /* Blinks an LED connected toport B*/

    BCF TRISB,0

    BCF PORTB,0

    LOOP:

    pausems .1000

    BSF PORTB, 0

    pausems .1000

    BSF PORTB, 0

    GOTO LOOP

    END ;control neverreaches here

    void main(void)

    {

    TRISB0 = 0;//Make RB0 output

    PORTB.RB0 = 0; // Make RB0 low

    while(1) //loop forever

    {

    __delay_ms(500); // 1s delay

    PORTB.RB0 = 1; // LED on

    __delay_ms(500); // 1s delay

    PORTB.RB0 = 0; // LED off

    }

    }

    C programAssembly program

  • 7/22/2019 Intoduction to Microcontrollers - PIC

    21/21

    Summary

    Microcontrollers are essentially micro-computers,

    with all the necessary components on one IC, (i.e.microprocessor core, memory and peripherals)

    Microchip offers plethora of devices, with varyingcapabilities and cost

    A lot of documentation and resources available

    Easy to use, inexpensive and are easily re-

    purposed.

    Low power consumption and high reliability