EXPERIMENT 4: Parallel Input/Output. Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing

Similar documents
Flow Charts and Assembler Programs

Binary Outputs and Timing

ECE Homework #3

The University of Texas at Arlington Lecture 5

Input/Output Ports and Interfacing

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

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

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

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

ECE Test #1: Name

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

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

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

Laboratory Exercise 7 - Extended I/O & Parallel Processing

Microchip 18F4550 Interface, Signal conditioning, USB, USB- RS-232, 16x2 LCD Interface

PIC 16F84A programming (II)

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

ME 515 Mechatronics. A microprocessor

Jordan University of Science and Technology Electrical Engineering Department Microcontrollers and Embedded Systems Spring 2011

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

Figure 1: Pushbutton without Pull-up.

LABORATORY MANUAL Interfacing LCD 16x2, Keypad 4x4 and 7Segment Display to PIC18F4580

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

CONNECT TO THE PIC. A Simple Development Board

Laboratory 10. Programming a PIC Microcontroller - Part II

Discrete Logic Replacement A Keypad Controller for Bi-directional Key Matrix

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

Assembly Language Instructions

Embedded System Design

Chapter 11: Interrupt On Change

PIC PROGRAMMING START. The next stage is always the setting up of the PORTS, the symbol used to indicate this and all Processes is a Rectangle.

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

Laboratory: Introduction to Mechatronics

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

Arithmetic,logic Instruction and Programs

Lecture (04) PIC16F84A (3)

CHAPTER 6 CONCLUSION AND SCOPE FOR FUTURE WORK

Physics 335 Intro to MicroControllers and the PIC Microcontroller

Target Board PIC877-TB - Reference Manual

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

The University of Texas at Arlington Lecture 3

ECE 354 Computer Systems Lab II. Memory and Indirect Addressing

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

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

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

APPLICATION NOTE Wire Communication with a Microchip PICmicro Microcontroller

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

Chapter 5. Problems All programming problems should include design pseudo code either as a separate design document on embedded comments in the code.

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING. BEng(Hons) Electrical and Electronics Engineering SEMESTER 1 EXAMINATION 2016/2017

Chapter 9. Input/Output (I/O) Ports and Interfacing. Updated: 3/13/12

These 3 registers contain enable, priority,

More (up a level)... Connecting the Nokia 3510i LCD to a Microchip PIC16F84 microcontroller

Introduction to Proteus

University of Hawaii EE 361L MPLab Quick Tutorial and Project 2.1 Last updated September 1, 2011

DESIGN AND FABRICATION OF FARE METER OF TAXICAB USING MICROCONTROLLER

APPLICATION NOTE 2361 Interfacing an SPI-Interface RTC with a PIC Microcontroller

Microcontrollers. Introduction to the PIC 8-bit Midrange Family. ECE Senior Design 15 February 2017

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.

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

Weekly Report: Interactive Wheel of Fortune Week 4 02/014/07-02/22/07 Written by: Yadverinder Singh

DERTS Design Requirements (1): Microcontroller Architecture & Programming

Application Note - PIC Source Code v1.1.doc

Lab 1 Introduction to Microcontroller

EEE394 Microprocessor and Microcontroller Laboratory Lab #6

SOLUTIONS!! DO NOT DISTRIBUTE PRIOR TO EXAM!!

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

Micro II and Embedded Systems

CENG 336 INT. TO EMBEDDED SYSTEMS DEVELOPMENT. Spring 2006

Lecture (04) PIC 16F84A programming I

Figure 1.1: Some embedded device. In this course we shall learn microcontroller and FPGA based embedded system.

EE6008-Microcontroller Based System Design Department Of EEE/ DCE

16.317: Microprocessor Systems Design I Fall 2013 Exam 3 Solution

Breeze Board. Type B. User Manual.

Locktronics PICmicro getting started guide

SOLAR TRACKING SYSTEM USING PIC16F84A STEPPER MOTOR AND 555TIMER

MPLAB -ICD USER S GUIDE

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

ET-PIC 24 WEB-V1. o Central Processing Unit (CPU) o System. o nanowatt Power Managed Modes. o Analog Features

Week1. EEE305 Microcontroller Key Points

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

Professor E. Ambikairajah UNSW Sydney

SOLUTIONS!! DO NOT DISTRIBUTE!!

Microprocessors B Lab 1 Spring The PIC24HJ32GP202

Model Answer Microcontrollers. MCQ Problems Total Q1 Q2

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

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

Embedded Systems Programming and Architectures

JUNEBUG PIC LABORATORY

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

Laboratory Exercise 5 - Analog to Digital Conversion

Timer2 Interrupts. NDSU Timer2 Interrupts September 20, Background:

Microcontroller Overview

UNIVERSITY OF BOLTON SCHOOL OF ENGINEERING B.ENG (HONS) ELECTRICAL AND ELECTRONIC ENGINEERING EXAMINATION SEMESTER /2016

PIC Discussion. By Eng. Tamar Jomaa

EECE.3170: Microprocessor Systems Design I Spring 2016

Contents. The USB Logic Tool... 2 Programming... 2 Using the USB Logic Tool... 6 USB Logic Tool Features... 7 Device Hardware...

ME 6405 Introduction to Mechatronics

Chapter 5 Sections 1 6 Dr. Iyad Jafar

Laboratory 9. Programming a PIC Microcontroller - Part I

CENG-336 Introduction to Embedded Systems Development. Timers

Transcription:

EXPERIMENT 4: Parallel Input/Output Objectives Introduction to the Parallel Input/Output (I/O) Familiarization to Interfacing Components' List: 1. Protoboard 2. 4 x pushbutton 3. 4 x 330Ω resistor 4. 4 x 4.7kΩ resistor 5. 4 x LED Pre lab 1. Design a program loop to create a time delay of 0.5sec and named it as delay05s. This program loop is to be run/ clocked by a 20MHz crystal oscillator. 2. Complete the Program 4.1 below. Introduction Overview of the PIC18F458 Parallel Ports. A PIC18F458 microcontroller has 5 I/O ports known as port A, B, C, D and E. The pins of an I/O port are often multifunctional with one or more peripheral functions e.g. interrupt, timer, analog to digital and etc. In general, when a peripheral function is enabled, that pin may not used as an I/O pin. Each I/O port has three register for its operation. These register are: TRIS register (data direction register) PORT register (reads the voltage levels on the pins device) LAT register (output latch) The register names for each port can be derived by adding the port name to these general register names. For example, port A has TRISA, PORTA and LATA registers. Reading and Writing the I/O Ports Data direction needs to be set before the I/O operation. In order to configure an I/O pin for input, set the associated bit in the TRIS register to 1. To configure an I/O pin for output, set the associated bit in the TRIS register to 0.

Port A is a 7-bit wide, bidirectional port. Table 4.1: PORTA function Port B is an 8-bit wide, bidirectional port. Table 4.2: PORTB function Port C is an 8-bit wide, bidirectional port. Table 4.3: PORTC function

Port D is an 8-bit wide, bidirectional port. Table 4.4: PORTD functions Port E is a 3-bit wide, bidirectional port. Table 4.5: PORTE functions Procedure 1. For this experiment, you will construct a simple circuit and complete a program with your design. The program being identifies which of four (4) switches is closed and each LED will turn ON according to the button pressed. SW1 corresponds to the LED at pin RB0, SW2 to RB1, SW3 to RB2 and SW4 to RB3. The LEDs should only turn ON as long as the switches are pressed. 2. The input and output external circuits are shown in Figure 4.1. 3. Build the output and input circuits on a breadboard

Figure 4.1 Circuit diagram of the switch and LED connection 4. Write the program below using the MPLAB #include <p18f458.inc> TEMP EQU 0X10 ORG 0X00 GOTO START START CLRF TRISB,A ; OUTPUT PORT B MOVLW 0XF0 MOVWF TRISD,A CLRF PORTB,A AGAIN CLRF PORTB BTFSS PORTD,7,A RCALL LED3 BTFSS PORTD,6,A RCALL LED2 BTFSS PORTD,5,A RCALL LED1 BTFSS PORTD,4,A RCALL LED0 BRA AGAIN LED3 MOVLW 8 MOVWF PORTB,A LED2. (Complete the program) LED1. (Complete the program) LED0. (Complete the program) delay05s (write the delay s program here) Program 4.1 5. Assemble the program using the MPLAB and download the program using the bootloader (MicroC). To do so, double-click the MikroC shortcut at the desktop.

6. Under Tool menu, select mikrobootloader. Figure 4.2 Select mikrobootloader 7. Click Connect. Once Connected message is displayed at the History Window, click Open HEX file to browse to your hex file and then click Start bootloader to download your program into the PIC. Figure 4.3 mikrobootloader menu 8. Execute and test your program on the board. Press the switches randomly. Write your observation in the worksheet.

9. By using the same circuit, write, assemble and execute the program below. Write your observation. #include <p18f458.inc> TEMP EQU 0X10 ORG 0X00 GOTO START START CLRF TRISB,A ; OUTPUT PORT B MOVLW 0XF0 MOVWF TRISD,A CLRF PORTB,A AGAIN CLRF PORTB BTFSS PORTD,7,A RCALL DO_SW3 BTFSS PORTD,6,A RCALL DO_SW2 BTFSS PORTD,5,A RCALL DO_SW1 BRA AGAIN DO_SW1 SETF PORTB CLRF PORTB DO_SW2 MOVLW 5 MOVWF 0X01 MOVLW 1 MOVWF TEMP LOOP2 DCFSNZ 0X01,F,A MOVFF TEMP,PORTB RLNCF TEMP,F,A BRA LOOP2 DO_SW3 MOVLW 0X5 MOVWF PORTB RCALL DELAY05s MOVLW 0XA MOVWF PORTB delay05s (write the delay s program here) Program 4.2 10. Draw the flowchart of the program for Program 4.2. 11. Switch off PIC18 board and logoff.

Special instructions on how to use Proteus 1. For this experiment, you may use the existing Proteus circuit design provided by your lab instructor to verify your source code if the hardware is not working/faulty. 2. Go to Start>All Programs>Proteus 7 Professional>ISIS 7 Professional. 3. Open the design file named Lab4.DSN provided by your lab instructor. 4. The circuit will appear in the workspace.

5. To run the simulation, you need to load the hex file first by right-clicking on the microcontroller and then click edit properties. 6. At the Edit Component menu: a) Under the Program File tab, select your hex file by clicking on the browse icon. b) Under the Processor Clock Frequency, select your desired clock frequency. c) Under Advanced Properties, select Enable Watchdog Timer and then select No. d) Finally, click OK. 7. Finally, click on the Play button at the bottom of the workspace to run the simulation.