25
Getting Started with Getting Started with PICs: PICs: Introducing Microcontrollers in Introducing Microcontrollers in Grade Twelve Computer Engineering Grade Twelve Computer Engineering Brad North Brad North

PICs.ppt

Embed Size (px)

Citation preview

Page 1: PICs.ppt

Getting Started with PICs:Getting Started with PICs:Introducing Microcontrollers in Introducing Microcontrollers in

Grade Twelve Computer EngineeringGrade Twelve Computer Engineering

Brad NorthBrad North

Page 2: PICs.ppt

AgendaAgenda

What is a Microcontroller? Where are Microcontrollers Used? Why Use Microcontrollers in G12? What You Need to Get Started P16F84 Characteristics “The PIC Process” Resources Questions

Page 3: PICs.ppt

What is a Microcontroller?What is a Microcontroller?

“A computer inside a chip”:– CPU– ROM– RAM– Bi-directional

ports– Interrupts– Internal clock– Many other

functions……

Page 4: PICs.ppt

Where Are Microcontrollers Where Are Microcontrollers Used?Used?

DVD, TV, VCR XBOX, Nintendo, Game Boy Carbon Monoxide Alarms PDAs, cellphones Automobiles Garage door openers Household appliances Automatic pilot systems Astronauts’ space suits

Page 5: PICs.ppt

Why Use Microcontrollers in G12?Why Use Microcontrollers in G12?

Students are highly motivated Potential to expand and

modify projects is unlimited Reasonably priced – P16F84 -

under $9 each Free Software and documents Covers many Ministry

Expectations

Page 6: PICs.ppt

Compare high-level and low-level programming languagesExplain how to determine memory requirements for information storageDescribe the function and interaction of a control unit, arithmetic logic unit, and memory registers in a simple CPUUse a diagram to illustrate how buses move data and instructions between memory and the CPU.Explain several computer-controlled systems that interact with real-world devices

ICE 4MO Ministry ICE 4MO Ministry Expectations …Expectations …

Page 7: PICs.ppt

……ICE 4M Ministry ICE 4M Ministry ExpectationsExpectations

Describe the constructs of a simple assembly or machine-level languageIdentify similarities and differences among memory addressing techniquesDesign an effective system consisting of a computer and interface that integrates input and output devicesWrite programs to process input and control output devices through interfacesWrite low-level programs

Page 8: PICs.ppt

What You Need To Get What You Need To Get StartedStarted

1. P16F84 & 18-pin DIP socket

2. 4 MHz crystal oscillator

3. Breadboard, 7805, LEDs, resistors

4. Programmer

5. Power adapter

6. Parallel port cable

Hardware

Page 9: PICs.ppt

• MPLAB IDE v5.70• Programmer Software • Programmer Firmware

Software

Documentation/Resources

• P16F84 Datasheet (.pdf)• MPLAB Manual and Tutorial (.pdf)

Page 10: PICs.ppt

P16F84 P16F84 CharacteristicsCharacteristics

DatasheetDatasheet

1024 x 14 program memory

68 x 8 User RAM Registers (data

memory)

13 Bi-directional ports

Internal oscillator

Interrupts

Page 11: PICs.ppt

1. Harvard Architecture 2 separate memory blocks , which

can be accessed simultaneously:i. Program Memoryii.Data Memory

Page 12: PICs.ppt

i. Program Memory Flash EEPROM – where your

program from assembler code is written to.

Program memory bus is 14 bits wide (Mid-Range PIC MCUs)

PIC16F84 has 1K x 14 bits of program memory space = 1,024 words x 14 bits

Addresses are in hex: last available address is 3FF

Page 13: PICs.ppt

ii. Data Memory

12 Special Function Registers (SFR) which control the PIC

68 General Purpose Registers (GPR)First GPR is 0ChLast is 4Fh

Page 14: PICs.ppt

2. Instruction Cycle/Clock Cycle• RISC – 35 Word Instruction Set• All instructions are processed in one

instruction cycle except for program branches (i.e. subroutine)

3. W (Working Register) 8-bit register – also referred to as the

"accumulator" in other MPUs ALL data must be placed into the W

register first, then moved from the W register to any other register (i.e. MOVLW, MOVF)

Page 15: PICs.ppt

““The PIC Process”The PIC Process”Coding & Assembling in MPLAB 5.70 Downloading to the programmer

using PICALLW

Building Circuit & testing, editing

Page 16: PICs.ppt

1. Write Source Code

Text editor (.asm file)

Page 17: PICs.ppt

RISC RISC Instruction Instruction SetSet

35 instructions Mnemonic

instructions and operands are the “commands” used to write the code

Page 18: PICs.ppt

Coding StructureCoding Structure

Label Field

Instruction, Directives Field

Data Field Comment Field

Page 19: PICs.ppt

2. Assemble Code (MPASM)2. Assemble Code (MPASM)

Page 20: PICs.ppt

.lst (list) file

3. Object Files Created3. Object Files Created

Page 21: PICs.ppt

.hex file

Page 22: PICs.ppt

4. Download to Programmer4. Download to Programmer

1. PICSTART PLUS– Download via

MPLAB

2. P16PRO/PICALL Download .hex file

via PICALLW

Page 23: PICs.ppt

ResourcesResources Documentation and MPLAB software

– www.microchip.com Programmer Software

– 2 options 1. PICSTART PLUS

– Part and parcel of MPLAB– $US200

2. P16PRO/PICALL– $US20/30 assembled– www.electronics123.com

Programmer Firmware (for P16PRO/PICALL)– $US20– www.picallw.com

Page 24: PICs.ppt

Additional ResourcesAdditional Resources

Easy PIC’n– Benson, David (www.sq-1.com)

Poptronics Magazine– PICtronics section (www.poptronics.com)

Page 25: PICs.ppt

?