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

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

Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 1.

PIC Discussion. By Eng. Tamar Jomaa

Laboratory: Introduction to Mechatronics

Chapter 2 Sections 1 8 Dr. Iyad Jafar

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

DERTS Design Requirements (1): Microcontroller Architecture & Programming

EEE111A/B Microprocessors

Micro II and Embedded Systems

Professor E. Ambikairajah UNSW Sydney

ME 515 Mechatronics. A microprocessor

Chapter 4 Sections 1 4, 10 Dr. Iyad Jafar

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

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

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

Learning Objectives:

Microcontroller systems Lec 2 PIC18LF8722 Microcontroller s s core

Mark II Aiken Relay Calculator

Microcontrollers. Microcontroller

ENE 334 Microprocessors

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

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

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

Assembly Language programming (1)

Embedded System Design

8051 Microcontrollers

Computer Hardware Requirements for ERTSs: Microprocessors & Microcontrollers

Lecture (04) PIC16F84A (3)

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


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

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

ECE 354 Introduction to Lab 1. February 5 th, 2003

TKT-3500 Microcontroller systems

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

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

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0501. Subject Name: Microprocessor Fundamentals & Programming

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Lecture Objectives. Introduction to Computing Chapter 0. Topics. Numbering Systems 04/09/2017

Microprocessors/Microcontrollers

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

SOLUTIONS!! DO NOT DISTRIBUTE!!

Microprocessors and Microcontrollers Prof. Santanu Chattopadhyay Department of E & EC Engineering Indian Institute of Technology, Kharagpur

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

PIC 16F84A programming (II)

Lecture 1. Course Overview and The 8051 Architecture

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

PIC16F8X 18-pin Flash/EEPROM 8-Bit Microcontrollers

Mod-5: PIC 18 Introduction 1. Module 5

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

Microcomputer Architecture and Programming

Input/Output Ports and Interfacing

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

INTRODUCTION OF MICROPROCESSOR& INTERFACING DEVICES Introduction to Microprocessor Evolutions of Microprocessor

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

Sencer Yeralan and Helen Emery Gainesville, Florida January 2000

Chapter 4. MARIE: An Introduction to a Simple Computer. Chapter 4 Objectives. 4.1 Introduction. 4.2 CPU Basics

The due date for submitting this assignment has passed. 1) Which of the following statements regarding a microcomputer, a

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

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

Instuction set

1. Internal Architecture of 8085 Microprocessor

EE 5340/7340 Motorola 68HC11 Microcontroler Lecture 1. Carlos E. Davila, Electrical Engineering Dept. Southern Methodist University

NEW CEIBO DEBUGGER. Menus and Commands

Ali Karimpour Associate Professor Ferdowsi University of Mashhad


LABORATORY USE OF A MICROCOMPUTER (Last Revision: August 27, 2000)

Explanation of PIC 16F84A processor data sheet Part 1: overview of the basics

The University of Texas at Arlington Lecture 3

1. Internal Architecture of 8085 Microprocessor

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

Fig 1. Block diagram of a microcomputer

Lecture Note On Microprocessor and Microcontroller Theory and Applications

ME 6405 Introduction to Mechatronics

ET355 Microprocessors Friday 6:00 pm 10:20 pm

Lecture (02) PIC16F84 (I)

8051 Microcontroller

Chapter 3: Further Microcontrollers

Assembly Language Programming of 8085

CSIBridge: Computer Science for Digital Forensics and Cyber Security

MICROPROCESSOR BASICS AND RELATED TERMS

acret Ameya Centre for Robotics & Embedded Technology Syllabus for Diploma in Embedded Systems (Total Eight Modules-4 Months -320 Hrs.

MICROCONTROLLERS 8051

8051 Microcontroller

Microprocessors I MICROCOMPUTERS AND MICROPROCESSORS

Introduction to Microcontrollers

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

Microprocessor and Microcontroller question bank. 1 Distinguish between microprocessor and microcontroller.

Introduction to Computers - Chapter 4

PIC16C63A/65B/73B/74B

Microprocessor (COM 9323)

Introduction to Microcontrollers

B.C.A 2017 MICROPROCESSOR AND ASSEMBLY LANGUAGE MODULE SPECIFICATION SHEET. Course Outline

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

Department of Electronics and Instrumentation Engineering Question Bank

Question Bank Microprocessor and Microcontroller

CONNECT TO THE PIC. A Simple Development Board

Transcription:

Laboratory: Introduction to Mechatronics Instructor TA: Edgar Martinez Soberanes (eem370@mail.usask.ca) 2015-01-12 Lab 2. PIC and Programming

Lab Sessions Lab 1. Introduction Read manual and become familiar with the operation and components of the car. Lab 2. Assemble the Mechanical and Electrical components of the car. Lab 3. Install the Software, debug the electronics and run the tutorial program. Lab 4. Program and run the sample programs for each module. Lab 5. Program the run the main software module to run the car and fine tune the car. Lab 6. Write up report and run the car on the test track and determine its performance. 2

Lab 2. PIC and Programming Outline Objective. Lecture. o o o o o PIC Architecture Addressing Registers Instruction set Programming Assemble of the car. Assignment s question 3. 3

Objective Develop an understanding of the 16F877 PIC s architecture to facilitate the programming of the self-guided car. 4

PIC Microcontroller (16F877) Microcomputer systems Every computer, no matter how simple or complex, has at its heart exactly two things: a CPU and some memory. Together, these two things are what make it possible for your computer to run programs. 5

A microcontroller is a simplified version of a similar architecture, placed on one chip 6

PIC Microcontroller (16F877) 7

Main Features Program memory (ROM) and Data memory (RAM) An accumulator (also called the working register, W) Separate data bus for program memory and data memory. 40-pin package. 5 bidirectional I/O ports 15 interrupts 35fixed width instructions 8 A/D input channels Implemented with Parallel Slave Port 8

Memory Organization. Flash Program Memory (ROM): o Size: 8K = 2 = 8192 o Word size = 14 bits. Data Memory (RAM): o Size: 368 = 2 + 112 o Word size = 1byte (1 byte = 8 bits) Data EEPROM (256 bytes) 9

Program Memory (ROM) CALL/GOTO (subroutines) Branching ROM within any 2K program memory page. 8K x 14 bits Stack space is not part of either ROM or RAM and the stack pointer is not readable or writable. 10

Data Memory (RAM) Memory: 2 = 512 o Divided in 4 banks Special Function Registers (SFR) General Purpose Registers (GPR) o Data Memory: 368 = 2 + 112 11

Data Memory Addressing Indirect: Using FSR register (File Select Register)and STATUS register bit IRP (bit 7). Direct: Using STATUS register bits RP1 & RP0 (bits 6 & 5) and specifying the address direction on the program (code). 12

Special Function Registers (SFR) SFR GPR (368 bytes) Total memory o Control the core" operation of the microcontroller. o Specific name, STATUS, FSR, PORTA, TRISA o No name but address number or direction. DATA MEMORY space. Likewise access. 13

STATUS Register Contains the arithmetic status of the ALU (Arithmetic Logic Unit), the RESET status and the bank select bits for data memory. Z, DC, and C bits are controlled by the device logic. TO and PD bits are not writable. o If, CLRF STATUS STATUS = 000u u1uu (u, unchanged) Only use BCF, BSF, SWAPF, and MOVEWF to alter the register. 14

W (Working) Register General register 8-bit wide. Does NOT have an specific direction within the Data Memory. A value in W can be added to another value or moved to file address. If another value is assigned the register's content is overwritten. 15

Ports 5 ports (A,B,C,D, and E). Each port has different characteristics and number of pins. Ports are bidirectional (Input/Output). Multi-functional. Some pins are multiplexed with an alternate function. When a peripheral is enable, that pin may not work as a general input/output. 16

Example Port A Register TRISA is used to set port A. PORTA is 6-bit wide, as well as TRISA. TRISA register (PORTA Data Direction Register): o bit = 1 (pin on port A = Input) o Bit = 0 (pin on port A = Output) 17

Program example (Initializing Port A): ADCON1 register is used to select digital options. 18

Instruction Set (Assembly Language) 35 single word instructions. Each instruction is a 14-bit word which includes: o o an opcode which specifies the instruction type and one or more operands which further specify the operation of the instruction. d = 0, store in W d = 1, store in f (f can be either SFR or GPR) Default d = 1. RAM memory address: 00h-7Fh Bank 0 80h-FFh Bank 1 100h-17Fh Bank 2 180h-1FFh Bank 3 19

Instruction Set. In general the instruction set is divided in three categories: o Byte-oriented o Bit-oriented o Literal and control operations 20

Programming on Assembly Each line of the source file (program code) may contain up to four types of information: o Labels o Mnemonics o Operands o Comments 21

Programming Maximum column width is 255 characters. White space (tabs) or a colon (:) must separate labels and mnemonics. White space (tabs) between mnemonics and operands. 22

Labels Must begin with an alpha character or an under bar (_). May contain alphanumeric characters. Must NOT begin with two underscores ( ), underscore and number (_2NDLOOP), or be a reserved word. Up to 32 characters. They are CASE sensitive. 23

Mnemonics Instruction set (35 instructions) on PIC 16F877 Data sheet. NOT case sensitive. http://www.mikroe.com/chapters/view/10/chapter-9-instruction-set/ 24

Operands Provide info to the instruction on the data that should be used and the storage location (variables or parameters). Multiple operands must be separated by commas. Comments Anything after a semicolon (;) 25

Numeric Constants and Radix MPASM assembler supports the following radix form for constants: hexadecimal, decimal, octal, binary, and ASCII. 26

Program example Turn on and off LEDs connected to the port A. 27

Programming the PIC 28

Programming Cycle 29

Hexadecimal Binary Hexadecimal Decimal 0000 0 0 0001 1 1 0010 2 2 0011 3 3 0100 4 4 0101 5 5 0110 6 6 0111 7 7 1000 8 8 1001 9 9 1010 A 10 1011 B 11 1100 C 12 1101 D 13 1110 E 14 1111 F 15 30

Thanks 31