Introduction to pic 16F877A

37
Microprocessor & Microcontroller Based Systems Lecture 1: Introduction to Microcontrollers By: Shahid S. Jan (Modified by Faizan Jawaid)

description

Introduction to pic Microcontroller 16F877A

Transcript of Introduction to pic 16F877A

Page 1: Introduction to pic 16F877A

Microprocessor & Microcontroller Based Systems

Lecture 1: Introduction to Microcontrollers

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

Page 2: Introduction to pic 16F877A

Course Online

Course web site: • Dropbox link

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

2

Page 3: Introduction to pic 16F877A

CLASS POLICY

Assignments must be submitted within the

Page 4: Introduction to pic 16F877A

Microcontroller

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

USB, CAN, PWM, ADC, etc.)

4

Page 5: Introduction to pic 16F877A

Microcontroller

5

Page 6: Introduction to pic 16F877A

Embedded Systems

6

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

Page 7: Introduction to pic 16F877A

Embedded Systems

7Intentionally left blank.

Page 8: Introduction to pic 16F877A

Embedded Systems Markets

1. Household

2. Entertainment

3. Automotive

4. Industry

5. Communication

6. Medical

8

Page 9: Introduction to pic 16F877A

1. Household

• Climate control (thermostats, furnaces, etc.)

• Sprinkler systems

• Home security systems

• Appliances– Microwaves, refrigerators, ovens, washing

machines, dish washers, etc.

• RFID

9

Page 10: Introduction to pic 16F877A

2. Entertainment

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

• Game consoles (Xbox, PS, Nintendo)

• iPod

• Digital cameras

10

Page 11: Introduction to pic 16F877A

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

Page 12: Introduction to pic 16F877A

3. Automotive (cont’d.)

• Antilock brakes

• Air bags

• Keyless entry

• Fuel injection

• Climate control

• GPS

12

Page 13: Introduction to pic 16F877A

4. Industrial

• ATM Machines

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

• Calculators

• Avionics

13

Page 14: Introduction to pic 16F877A

4. Industrial (cont’d.)

• Test equipment (scopes, meters, etc.)

• Robotics

• Ultrasound M/c

• Electronic tolls

14

Page 15: Introduction to pic 16F877A

5. Communications

• Cell phones

• Answering machines, fax machines

• PDAs

• Wireless radio

• RFID

15

Page 16: Introduction to pic 16F877A

6. Medical Applications

• Dialysis

• Electronic Surgical equipment

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

• Imaging (Ultrasound, MRI, X-Ray)

16

Page 17: Introduction to pic 16F877A

Embedded Systems Market

• Worldwide PC sales in 2008:256 million units

• Worldwide microcontroller sales in 2008:11 billion units

17

Page 18: Introduction to pic 16F877A

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

Page 19: Introduction to pic 16F877A

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

Page 20: Introduction to pic 16F877A

Automotive Applications

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

20

Page 21: Introduction to pic 16F877A

DSPs

• Two largest DSP customers: Nokia and Motorola

• Wireless phones comprise 85% of DSP market

21

Page 22: Introduction to pic 16F877A

DSP Market

22

Page 23: Introduction to pic 16F877A

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

Page 24: Introduction to pic 16F877A

Microchip PIC

• Microchip makes almost 400 different microcontrollers

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

24

Page 25: Introduction to pic 16F877A

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

Page 26: Introduction to pic 16F877A

Memory Types

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

26

Page 27: Introduction to pic 16F877A

PIC Programming

27

EEPROM Programmer – interfaces with Microchip software

Page 28: Introduction to pic 16F877A

EPROM Eraser

28

Page 29: Introduction to pic 16F877A

In Circuit Debugger: Olimex ICD 1

Available from Sparkfun

RS232 interfacePower supply required

29

Page 30: Introduction to pic 16F877A

In-Circuit Debugger: PICkit 2

30

Mirochip Inc.

USB interfacePower supply is not required

Page 31: Introduction to pic 16F877A

Lab Setup

31

PC

ICD

Breadboard

PICPIC

powersupply(ICD1 only)

USB orRS232

6-pincable

powersupply

header

MPLAB

Page 32: Introduction to pic 16F877A

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

Page 33: Introduction to pic 16F877A

Program Memory

• 8K words, 14 bits each

• 8K = 8 1024 = 8192 = 0x2000

• Addresses 0x0000–0x1FFF

• Addresses are 13 bits

3333

Page 34: Introduction to pic 16F877A

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

Page 35: Introduction to pic 16F877A

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

Page 36: Introduction to pic 16F877A

Harvard Architecture

PIC16F877 bus widths

36

Program Memory

CPUData

Memory

Instruction14 bits

Address13 bits

Data8 bits

Address9 bits

36

Page 37: Introduction to pic 16F877A

The End