Introduction to pic 16F877A

Post on 20-Oct-2015

208 views 10 download

description

Introduction to pic Microcontroller 16F877A

Transcript of Introduction to pic 16F877A

Microprocessor & Microcontroller Based Systems

Lecture 1: Introduction to Microcontrollers

By: Shahid S. Jan (Modified by Faizan Jawaid)

Course Online

Course web site: • Dropbox link

– Syllabus, lecture slides, assignments, solutions, project guidelines, reference/reading material etc.

2

CLASS POLICY

Assignments must be submitted within the

Microcontroller

• Elements of a microcontroller– Microprocessor– I/O ports– Memory– Counters and timers– Special purpose interface devices (RS232,

USB, CAN, PWM, ADC, etc.)

4

Microcontroller

5

Embedded Systems

6

Embedded systems are special purpose computing systems designed to perform specific task(s).

Embedded Systems

7Intentionally left blank.

Embedded Systems Markets

1. Household

2. Entertainment

3. Automotive

4. Industry

5. Communication

6. Medical

8

1. Household

• Climate control (thermostats, furnaces, etc.)

• Sprinkler systems

• Home security systems

• Appliances– Microwaves, refrigerators, ovens, washing

machines, dish washers, etc.

• RFID

9

2. Entertainment

• TV, DVD/BR players, Remote Controllers, etc.

• Game consoles (Xbox, PS, Nintendo)

• iPod

• Digital cameras

10

3. Automotive

• 50–100 embedded systems in autos

• 10–15 million lines of C code

• 35–45 micros per automobile

• BMW has a max of 70 micros

11

3. Automotive (cont’d.)

• Antilock brakes

• Air bags

• Keyless entry

• Fuel injection

• Climate control

• GPS

12

4. Industrial

• ATM Machines

• Computer equipment (networks, printers, mouse devices, disk drives, etc.)

• Calculators

• Avionics

13

4. Industrial (cont’d.)

• Test equipment (scopes, meters, etc.)

• Robotics

• Ultrasound M/c

• Electronic tolls

14

5. Communications

• Cell phones

• Answering machines, fax machines

• PDAs

• Wireless radio

• RFID

15

6. Medical Applications

• Dialysis

• Electronic Surgical equipment

• Monitoring (ECG, EEG, blood pressure, ...)

• Imaging (Ultrasound, MRI, X-Ray)

16

Embedded Systems Market

• Worldwide PC sales in 2008:256 million units

• Worldwide microcontroller sales in 2008:11 billion units

17

Embedded Systems Growth

MPU MCU DSP Total

2004 30,488

12,449

7,798 50,734

2005 34,970

12,082

7,635 54,687

2006 37,605

12,837

9,083 59,526

2007 44,141

13,981

11,046

69,168

2008 45,280

14,686

11,391

71,358

2009 52,020

16,399

13,205

81,624

2010 56,154

17,805

15,996

89,956

2011 61,331

18,864

17,664

97,859

CAGR 10% 8% 14% 10%

MPU = microprocessors

MCU = microcontrollers

DSP = digital signal processors

World market, millions of dollars

CAGR = compounded annual growth rate

Source: DSP Outperforms.pdf18

Embedded Systems Growth

Microcontrollers only

Sales in millions of dollars

Units in millions

Source: Market1.doc, http://www.electronics.ca/presscenter/articles/580/1/New-Study-Predicts-10-percent-Growth-for-Microcontrollers/Page1.html

Sales Units Price/unit

2004 12,449 6,930 $1.80

2005 12,082 7,081 $1.71

2006 12,446 8,464 $1.47

2007 13,716 10,233 $1.34

2008 15,631 11,255 $1.39

2009 16,272 11,831 $1.38

2010 17,723 13,502 $1.31

2011 19,204 14,450 $1.33

2012 20,480 15,765 $1.30

2007-12CAGR

8% 9% –1%

19

Automotive Applications

• Microcontrollers in automobiles– $5.8 billion in 2006– $9.5 billion in 2010

20

DSPs

• Two largest DSP customers: Nokia and Motorola

• Wireless phones comprise 85% of DSP market

21

DSP Market

22

Microcontroller Market

• 2005: 8-bit market about $5 billion, led by Microchip Inc. (24%)16-bit market about $5 billion

• Over 40 microcontroller manufacturersTI, Motorola, Freescale, Atmel, Parallax, National, Intel, Zilog, Hitachi/Mitsubishi/Renesas, Cypress, Holtek, Rabbit, Toshiba, NEC, Philips, Sanyo, Matsushita, Sony, LG Semicon, Samsung, Siemens, Toshiba, Fujitsu, Semtech, …

23

Microchip PIC

• Microchip makes almost 400 different microcontrollers

• Microchip Advanced Parts Selector software available at www.microchip.com

24

25

Datasheet p. 1

PIC = peripheral interface controller

Max clock freq.• 4 MHz• 10 MHz• 20 MHz

1 instr. every 4 or 8 clock cycles

PIC 16F877

Memory Types

• ROM• PROM• EPROM (OTP)• EEPROM (Flash)• RAM

26

PIC Programming

27

EEPROM Programmer – interfaces with Microchip software

EPROM Eraser

28

In Circuit Debugger: Olimex ICD 1

Available from Sparkfun

RS232 interfacePower supply required

29

In-Circuit Debugger: PICkit 2

30

Mirochip Inc.

USB interfacePower supply is not required

Lab Setup

31

PC

ICD

Breadboard

PICPIC

powersupply(ICD1 only)

USB orRS232

6-pincable

powersupply

header

MPLAB

Microchip PIC Features

• High performance RISC CPU

• Only 35 single word instructions to learn

• 8K 14-bit words of FLASH Program Memory

• 368 bytes of general purpose data memory (RAM)

• 256 bytes of EEPROM Data Memory

• Interrupt capability (14 sources)

• Eight level deep hardware stack

• Watchdog timer ( will be discussed in lectures )

• Programmable code protection

• Power saving SLEEP mode3232

Program Memory

• 8K words, 14 bits each

• 8K = 8 1024 = 8192 = 0x2000

• Addresses 0x0000–0x1FFF

• Addresses are 13 bits

3333

34

Datasheet p. 136

35 instructions1 or 2 instr. cycles14 bits/instruction

Example:goto 0x3A2 =10 1011 1010 0010 =0x2BA2

Assembly code Assembler Machine code

34

35

Datasheet p. 13

8-bit data words

368 bytes of data RAM, which is fast but volatile

256 bytes of data EEPROM,which is slow but nonvolatile(not shown on this page)

GPRs: 96+80+96+96 = 368 bytes

35

Harvard Architecture

PIC16F877 bus widths

36

Program Memory

CPUData

Memory

Instruction14 bits

Address13 bits

Data8 bits

Address9 bits

36

The End