Upload
flashdomain
View
1.708
Download
0
Tags:
Embed Size (px)
Citation preview
Getting Started with PICs:Getting Started with PICs:Introducing Microcontrollers in Introducing Microcontrollers in
Grade Twelve Computer EngineeringGrade Twelve Computer Engineering
Brad NorthBrad North
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
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……
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
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
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 …
……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
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
• MPLAB IDE v5.70• Programmer Software • Programmer Firmware
Software
Documentation/Resources
• P16F84 Datasheet (.pdf)• MPLAB Manual and Tutorial (.pdf)
P16F84 P16F84 CharacteristicsCharacteristics
DatasheetDatasheet
1024 x 14 program memory
68 x 8 User RAM Registers (data
memory)
13 Bi-directional ports
Internal oscillator
Interrupts
1. Harvard Architecture 2 separate memory blocks , which
can be accessed simultaneously:i. Program Memoryii.Data Memory
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
ii. Data Memory
12 Special Function Registers (SFR) which control the PIC
68 General Purpose Registers (GPR)First GPR is 0ChLast is 4Fh
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)
““The PIC Process”The PIC Process”Coding & Assembling in MPLAB 5.70 Downloading to the programmer
using PICALLW
Building Circuit & testing, editing
1. Write Source Code
Text editor (.asm file)
RISC RISC Instruction Instruction SetSet
35 instructions Mnemonic
instructions and operands are the “commands” used to write the code
Coding StructureCoding Structure
Label Field
Instruction, Directives Field
Data Field Comment Field
2. Assemble Code (MPASM)2. Assemble Code (MPASM)
.lst (list) file
3. Object Files Created3. Object Files Created
.hex file
4. Download to Programmer4. Download to Programmer
1. PICSTART PLUS– Download via
MPLAB
2. P16PRO/PICALL Download .hex file
via PICALLW
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
Additional ResourcesAdditional Resources
Easy PIC’n– Benson, David (www.sq-1.com)
Poptronics Magazine– PICtronics section (www.poptronics.com)
?