ME 6405 Introduction to Mechatronics

Similar documents
Embedded System Design

Embedded Systems Design (630470) Lecture 4. Memory Organization. Prof. Kasim M. Al-Aubidy Computer Eng. Dept.

EEE111A/B Microprocessors

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

Learning Objectives:

which means that writing to a port implies that the port pins are first read, then this value is modified and then written to the port data latch.

PIC16C84. 8-bit CMOS EEPROM Microcontroller PIC16C84. Pin Diagram. High Performance RISC CPU Features: CMOS Technology: Peripheral Features:

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002. Semester 2. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J2. Time allowed: 3 Hours

M PIC16F84A. 18-pinEnhanced FLASH/EEPROM 8-Bit Microcontroller. High Performance RISC CPU Features: Pin Diagrams. Peripheral Features:

Embedded Systems. PIC16F84A Internal Architecture. Eng. Anis Nazer First Semester

UNIVERSITY OF ULSTER UNIVERSITY EXAMINATIONS : 2001/2002 RESIT. Year 2 MICROCONTROLLER SYSTEMS. Module Code: EEE305J1. Time allowed: 3 Hours

NH-67, TRICHY MAIN ROAD, PULIYUR, C.F , KARUR DT. DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING COURSE MATERIAL

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

PIC16F8X. 8-Bit CMOS Flash/EEPROM Microcontrollers PIC16F8X PIC16CR8X. Pin Diagram. Devices Included in this Data Sheet:

Section 11. Timer0. Timer0 HIGHLIGHTS. This section of the manual contains the following major topics:

PIC 16F84A programming (II)

EE 361L Digital Systems and Computer Design Laboratory

ME 515 Mechatronics. A microprocessor

Laboratory 9. Programming a PIC Microcontroller - Part I

DERTS Design Requirements (1): Microcontroller Architecture & Programming

PIC Discussion By Eng. Tamar Jomaa

PIC16F84A. 18-pin Enhanced Flash/EEPROM 8-Bit Microcontroller. Devices Included in this Data Sheet: Pin Diagrams. High Performance RISC CPU Features:

Outlines. PIC Programming in C and Assembly. Krerk Piromsopa, Ph.D. Department of Computer Engineering Chulalongkorn University

Lecture (04) PIC16F84A (3)

PIC Discussion By Eng. Tamar Jomaa

Section 13. Timer0 HIGHLIGHTS. Timer0. This section of the manual contains the following major topics:

When JP1 is cut, baud rate is Otherwise, baud rate is Factory default is that JP1 is shorted. (JP1 is jumper type in some model)

ME 475 Lab2 Introduction of PIC and Programming. Instructor: Zhen Wang

PIC16F8X PIC16F8X. 18-pin Flash/EEPROM 8-Bit Microcontrollers

Micro II and Embedded Systems

Hardware Interfacing. EE25M Introduction to microprocessors. Part V. 15 Interfacing methods. original author: Feisal Mohammed

Chapter 2 Sections 1 8 Dr. Iyad Jafar

These 3 registers contain enable, priority,

Hi Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

PIC16C432 OTP 8-Bit CMOS MCU with LIN bus Transceiver

Embedded Systems. PIC16F84A Sample Programs. Eng. Anis Nazer First Semester

CENG-336 Introduction to Embedded Systems Development. Timers

Lecture (02) PIC16F84 (I)

Dept. of Computer Engineering Final Exam, First Semester: 2016/2017

Lesson 14. Title of the Experiment: Introduction to Microcontroller (Activity number of the GCE Advanced Level practical Guide 27)

ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 6

Input/Output Ports and Interfacing

LAB WORK 2. 1) Debugger-Select Tool-MPLAB SIM View-Program Memory Trace the program by F7 button. Lab Work

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet... 4

Microcontroller Overview

Midrange 8b PIC Microcontrollers. ECE Senior Design 14 February 2017

Week1. EEE305 Microcontroller Key Points

1 Introduction to Computers and Computer Terminology Programs Memory Processor Data Sheet Example Application...

PIC16F /40-Pin 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram PDIP. Microcontroller Core Features:

Assembly Language Instructions

Outline. Micriprocessor vs Microcontroller Introduction to PIC MCU PIC16F877 Hardware:

The University of Texas at Arlington Lecture 5

Section 16. Basic Sychronous Serial Port (BSSP)

/* PROGRAM FOR BLINKING LEDs CONEECTED TO PORT-D */

University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory

Embedded systems. Exercise session 3. Microcontroller Programming Lab Preparation

PIC Discussion. By Eng. Tamar Jomaa

Flow Charts and Assembler Programs

Chapter 11: Interrupt On Change

PIC16F870/ /40-Pin, 8-Bit CMOS FLASH Microcontrollers. Devices Included in this Data Sheet: Pin Diagram. Microcontroller Core Features:

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

University of Dayton. Electrical & Computer Engineering. ECE 536 Microprocessor Applications. Dr. Ralph Barrera. Assignment (4)

D:\PICstuff\PartCounter\PartCounter.asm

Microcontrollers. Microcontroller

ECE 354 Introduction to Lab 2. February 23 rd, 2003

Lecture (04) PIC 16F84A programming I

PIC16C62X Data Sheet. EPROM-Based 8-Bit CMOS Microcontrollers Microchip Technology Inc. DS30235J

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Lecture (03) PIC16F84 (2)

THE UNIVERSITY OF THE WEST INDIES

PIC16C52. EPROM-Based 8-Bit CMOS Microcontroller PIC16C52. Pin Diagrams. Feature Highlights. High-Performance RISC CPU. Peripheral Features

ME4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics. Instructor: Professor Charles Ume LECTURE 7

AN587. Interfacing to an LCD Module. Interfacing to an LCD Module INTRODUCTION OPERATION CONTROL SIGNAL FUNCTIONS TABLE 2: CONDITIONAL ASSEMBLY FLAGS

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 2. PIC and Programming

Interrupts. ELEC 330 Digital Systems Engineering Dr. Ron Hayne. Images Courtesy of Ramesh Gaonkar and Delmar Learning

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

ECE 354 Computer Systems Lab II. Interrupts, Strings, and Busses

PIC Architecture & Assembly Language Programming. Hsiao-Lung Chan Dept Electrical Engineering Chang Gung University, Taiwan

SOLUTIONS!! DO NOT DISTRIBUTE!!

Microcomputer Architecture and Programming

PIC16F818/819 Data Sheet

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING. EE6008 Microcontroller based system design

Section 4. Architecture

TOPIC 3 INTRODUCTION TO PIC ASSEMBLY LANGUAGE. E4160 Microprocessor & Microcontroller System. Prepared by : Puziah Yahaya JKE, POLISAS / DEC 2010

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

16.317: Microprocessor-Based Systems I Spring 2012

Introduction. Embedded system functionality aspects. Processing. Storage. Communication. Transformation of data Implemented using processors

To Our Valued Customers

Performance & Applications

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

Documentation Design File Formats

Microprocessors/Microcontrollers

C and Embedded Systems. So Why Learn Assembly Language? C Compilation. PICC Lite C Compiler. PICC Lite C Optimization Results (Lab #13)

C Language Programming, Interrupts and Timer Hardware

PIC16F630/676 Data Sheet

Interrupts on PIC18F252 Part 2

Introduction to general architectures of 8 and 16 bit micro-processor and micro-controllers

CHAPTER 1. Introduction to Microcontrollers. Introduction

Transcription:

ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Microchip PIC

Manufacturer Information: Company: Website: http://www.microchip.com Reasons for success: Became the hobbyist's favorite microcontroller. (Also the microcontroller used in the popular Basic Stamps) Many microcontroller variations so developer can choose optimal microcontroller for a project.

3 major categories: 12 bit instruction core 16C5X, 12C5XX, 10F2XX family (33 instructions) (no interrupts) (2 level stack, can only make 2 nested calls) ( 10F2XX smallest microcontroller. 6-pins. 4 pins available for I/0) 14 bit instruction core 16C5XX,16C62X, 16C6X, 16C7X, 16C8X, 16F8X, 12C6XX,16C9XX, 14C000 family (35 instructions) (8 level stack) 16 bit instruction core 18FXX family (75 instructions) (31 level stack) (Only category that can execute a program from external memory and write to program memory)

Variations within a family:

Microchip PIC Samples: Samples can be ordered from Microchip every 3 months per person An order can have 3 each of 5 different micro-controllers

Device Programmer Options: Microchip ICD2 Programmer/Debugger From the makers of the microcontrollers themselves. Updatable firmware, compatible with all current products Cost: $159 Parallax PIC Programmer From the makers of the Basic Stamp PIC 16C58A can be programmed with Basic Stamp Code Cost: $199 Various Hobbyist Programmers: Many schematics for programmers on the net. Some that could be built for $10. (Note: Usually limited to one category or family)

Program Language Options: Assembly Language: Microchip allows free downloads of their assembler and simulator called MPLAB C Language: Microchip (Note:Only works on PIC18FXXX MCU s) Custom Computer Services (CCS) (Note: Probably the best) C2C (Note: Not very good but can also handle Senix SX chips) Various others (including free ones for specific families) Basic: PicBasic

CPU Registers: Microchip PIC microcontrollers have only one CPU register, W. W is one byte. This has the effect of limiting data per instruction to one byte. (Note: Program counter and Condition Code register equivalents are regular registers for Microchip PIC micro-controllers. Stack Pointer is not accessible.) Motorola HC11 microcontrollers have several CPU registers: Accumulator A, Accumulator B, Accumulator D, Index X, Index Y, Program counter PC, Stack Pointer SP, and Condition Code register C.

RISC vs. CISC: Microchip PIC microcontrollers are RISC (Reduced Instruction Set Computer). RISC keeps the number of instructions small so each op-code takes up only 1 byte of storage space. Usually each instruction takes only 1 cycle to execute. Motorola HC11 are CISC ( Complex Instruction Set Computer). These have a large instruction set that can do much more in a single instruction. A single instruction may take many byte of program space and more than 1 cycle to execute.

Memory Organization: Microchip PIC microcontrollers use Harvard Architecture for memory Harvard Architecture separates File Registers ( this includes user data ram and registers) and Program memory address space. (Note: File Registers and Program memory on two separate buses. This enables the CPU to get both an op-code and data in one clock cycle.) Usually Program memory is not addressable meaning user program cannot read or write to Program memory. (Note: EEPROM Data is also kept separate from File Registers and Program memory in Microchip PICs and can be addressed through File registers). Motorola HC11 use Von Neumann Architecture for memory All memory is kept together in one address space.( Note: one bus) All memory can be addressed by program (Note: useful for self changing code) George George W. W. Woodruff School School of of Mechanical Engineering, Georgia Georgia Tech Tech

Interrupt Vectors: Microchip PIC microcontrollers have only one Interrupt Vector for all interrupts. Programmer must determine which interrupt to service within Interrupt Service Routine. Motorola HC11 microcontrollers have an Interrupt Vector for each interrupt source.

Binary, Decimal,Hexadecimal, and ASCII Syntax: Type Syntax Example Decimal D'<digits>' D'100'.<digits>.100 (Note: does not mean 1/10 th ) Hexadecimal H'<hex_digits> H'9f' 0x<hex_digits> 0x9f Binary B'<binary_digits>' B'00111001 ASCII A'<character>' A'C' '<character> 'C

Example PIC16F84: Package and Pin outs MCLR: Master Clear VSS: Ground VDD: 5 Volts RA: Bi-Directional I/O pins RB: Bi-Directional I/O pins (Note: Edge interrupt available on RB pins 4-7. RB0 can also be used as a separate external interrupt. Timer overflow interrupt. Data EEPROM Write Complete interrupt)

Example PIC16F84 Minimum Supporting Circuitry:

Example PIC16F84: Program Memory Space Program execution starts at reset Vector One Interrupt Vector This memory cannot be addressed by user program

Example PIC16F84: File Registers This memory space is further divided into 2 banks Which bank to access is controlled by STATUS register (Bit 5 low = bank 0. Bit 5 high = bank1.) Lower 3 bits of STATUS register is equivalent to the Condition Code register math flags in HC11 PCL contains lower byte of Program counter PCLATH contains upper 5 bits of Program counter (NOTE: Program counter is only 13 bits) 0Ch 4Fh is user ram data

Example PIC16F84: File Registers (continued) TMRO is the timer. Similar to TCNT register in HC11. Option bit 7: RBPU: PORTB Pull-up Enable bit 1 = PORTB pull-ups are disabled 0 = PORTB pull-ups are enabled (by individual port latch values) bit 6: INTEDG: Interrupt Edge Select bit 1 = Interrupt on rising edge of RB0/INT pin 0 = Interrupt on falling edge of RB0/INT pin bit 5: T0CS: TMR0 Clock Source Select bit 1 = Transition on RA4/T0CKI pin 0 = Internal instruction cycle clock (CLKOUT) bit 4: T0SE: TMR0 Source Edge Select bit 1 = Increment on high-to-low transition on RA4/T0CKI pin 0 = Increment on low-to-high transition on RA4/T0CKI pin bit 3: PSA: Prescaler Assignment bit bit 2-0: PS2:PS0: Prescaler Rate Select bits TRISA/B is for direction input (1) /output (0) control. Similar to data direction registers in HC11. FSR and 0x00 used for indirect addressing. Similar to George George W. W. Woodruff School School Index of of Mechanical CPU registers Engineering, HC11. Georgia Georgia Tech Tech

Example PIC16F84: File Registers (continued) INTCON is for interrupt Control bit 7: GIE: Global Interrupt Enable bit 1 = Enables all un-masked interrupts 0 = Disables all interrupts bit 6: EEIE: EE Write Complete Interrupt Enable bit 1 = Enables the EE write complete interrupt 0 = Disables the EE write complete interrupt bit 5: T0IE: TMR0 Overflow Interrupt Enable bit 1 = Enables the TMR0 interrupt 0 = Disables the TMR0 interrupt bit 4: INTE: RB0/INT Interrupt Enable bit 1 = Enables the RB0/INT interrupt 0 = Disables the RB0/INT interrupt bit 3: RBIE: RB Port Change Interrupt Enable bit 1 = Enables the RB port change interrupt 0 = Disables the RB port change interrupt bit 2: T0IF: TMR0 overflow interrupt flag bit 1 = TMR0 has overflowed (must be cleared in software) 0 = TMR0 did not overflow bit 1: INTF: RB0/INT Interrupt Flag bit 1 = The RB0/INT interrupt occurred 0 = The RB0/INT interrupt did not occur bit 0: RBIF: RB Port Change Interrupt Flag bit 1 = When at least one of the RB7:RB4 pins changed state George George W. W. Woodruff School School of of Mechanical Engineering, Georgia Georgia Tech Tech (must be cleared in software) 0 = None of the RB7:RB4 pins have changed state

Example PIC16F84: EEPROM Data Memory Space Addresses available: 00h 3Fh Access is controlled by EEDATA, EEADR, and EECON1 registers. (NOTE: EECON2 is not active in this PIC) Remember the EEPROM Data memory is separated from Program memory and File Registers.

Example PIC16F84: Instructions

Example PIC16F84: Instructions

Assembly example: When RB4 transitions from low to high, copy TMRO register to user data ram at 0x0C. #define PORTB 0x06 #define TMRO 0x01 #define STATUS 0x03 #define OPTION 0x01 #define TRISB 0x06 #define INTCON 0x0B #define TEMP 0x0C ORG 0x00 GOTO MAIN ; Note for OPTION: OPTION is located at file address 0x81 ; but file instructions only take 0x00 to 0x7F. When file address bank 1 ; is selected, micro-controller automatically adds 0x80 therefore ; 0x81 0x80 = 0x01. Similar for TRISB located at 0x86 ; Start Program at reset vector ; Jump over the Interrupt Service Routine ORG 0x04 ; Interrupt Service routine beginning located at Interrupt Vector MOVF TMRO,0 ; Move timer to W CPU Register MOVWF TEMP ; Move W CPU Register to memory location 0x0C BCF INTCON,0 ; Clear RB change interrupt flag RTFIE ; Return from Interrupt George George W. W. Woodruff School School of of Mechanical Engineering, Georgia Georgia Tech Tech

Assembly example (Continued): When RB4 transitions from low to high, copy TMRO register to user data ram at 0x0C. MAIN LOOP BSF STATUS,5 BSF TRISB,5 MOVLW 0xC0 MOVWF OPTION BCF STATUS,5 MOVLW 0x88 MOVWF INTCON GOTO LOOP END ;Select Bank 1 by setting bit 5 of status register ; Make RB4 an input by setting bit 5 of Tristate B ; move 0xC0 to W CPU register ; Setup the options including RB interrupt configuration ; Select Bank 0 by clearing bit 5 of status register ; move 0x88 to W CPU register ; turn on RB change and Global interrupts also clear flag ; Infinite LOOP

C example (using CCS) for demo board: #include <16F84.h> #use Delay(clock=4000000) #define true 1 #byte PORTB = 0x06 #byte PORTA = 0x05 #int_rb rb_isr(){ delay_ms(10); if(portb & 0x80){ while(portb & 0x80){ PORTA = 0x00; } PORTA = 0x0F; } if(portb & 0x40){ while(portb & 0x40){ PORTA++; PORTA = PORTA & 0x0F; delay_ms(20); } PORTA = 0x0F; } George George W. W. Woodruff School School of of Mechanical Engineering, Georgia Georgia Tech Tech } void main(void){ set_tris_a(0x00); set_tris_a(0xc0); enable_interrupts(global); enable_interrupts(int_rb); PORTA = 0x0F; while(true); }