Embedded System Spring, 2011 Lecture 9: I/O Programming Eng. Wazen M. Shbair.

Slides:



Advertisements
Similar presentations
PROGRAMMABLE PERIPHERAL INTERFACE -8255
Advertisements

Suranaree University Of Technology มทส  2002 Anant Oonsivilai 2002/2/25 Microcomputers and Microprocessors 1 Chapter 4 I/O Port Programming.
Input/Output Ports and Interfacing ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
CHAPTER 4 I/O PORT PROGRAMMING. I/O Port Pins The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins All the ports upon RESET are configured as input,
Microprocessor and Microcontroller Based Systems Instructor: Eng.Moayed N. EL Mobaied The Islamic University of Gaza Faculty of Engineering Electrical.
By Muhammad Ali Mazidi, Rolin McKinlay, Danny Causey
Prof. Jorge A. Ramón Introducción a Microcontroladores.
Eng. Husam Alzaq The Islamic Uni. Of Gaza
Eng. Husam Alzaq The Islamic Uni. Of Gaza
Microprocessor Systems Design I Instructor: Dr. Michael Geiger Fall 2013 Lecture 26: PIC microcontroller intro.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 29: Microcontroller intro.
Microcontroller Architecture— PIC18F Family
Railway Foundation Electronic, Electrical and Processor Engineering.
Microcontroller Architecture PIC18F Family
Embedded System Spring, 2011 Lecture 3: The PIC Microcontrollers Eng. Wazen M. Shbair.
Microcontroller Programming How to make something almost do something else Raffi Krikorian MAS November 2003.
Department of Electronic & Electrical Engineering Embedded system Aims: Introduction to: Hardware. Software Ideas for projects ? Robotics/Control/Sensors.
Today’s Lecture List the Timers of PIC18 and their associated registers Describe the various modes of the PIC18 timers Program the PIC18 timers in Assembly.
1 EKT 225 MICROCONTROLLER I CHAPTER 3 I/O PORT PROGRAMMING.
Khaled A. Al-Utaibi  Intel Peripheral Controller Chips  Basic Description of the 8255  Pin Configuration of the 8255  Block Diagram.
Embedded Systems Design 1 Lecture Set 6 I/O Ports.
Input/Output mechanisms
Building Assembler Programs Chapter Five Dr. Gheith Abandah1.
I/O Ports CS-280 Dr. Mark L. Hornick 1. CS-280 Dr. Mark L. Hornick 2 Ports are channels from the CPU to external hardware and software Atmega32 has: 4.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
The 8051 Microcontroller and Embedded Systems
Interrupts and DMA CSCI The Role of the Operating System in Performing I/O Two main jobs of a computer are: –Processing –Performing I/O manage and.
I/O PORTS (Simplest Peripherals) PORT A: 6 bits wide (7th and 8th bit always read as 0) PORT B: 8 bits wide PORT C: 8 bits wide PORT D: 8 bits wide.
Teachers Name : Suman Sarker Telecommunication Technology Subject Name : Microcontroller & Embedded System Subject Code : 6871 Semester : 7th Department.
One of the most important feature of the microcontroller is a number of input/output pins used for connection with peripherals. In the case of PIC 167CX,
Embedded System Spring, 2011 Lecture 4: The PIC Microcontrollers Eng. Wazen M. Shbair.
Embedded System Spring, 2011 Lecture 10: Arithmetic, Logic Instruction and Programs Eng. Wazen M. Shbair.
MICROPROCESSOR AND MICRO CONTROLLER
Embedded System Spring, 2011 Lecture 5: The PIC Microcontrollers Eng. Wazen M. Shbair.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
Chapter 7 Larger Systems and the PIC 16F873A The aims of this chapter are to introduce: The architecture of the 16F873A microcontroller; The 16F873A memory.
Today’s Lecture Unconditional branch instruction
Eng. Husam Alzaq The Islamic Uni. Of Gaza
I/O Ports MTT I/O PORTS. I/O Ports MTT Module Objectives Configure any pin as either input or output Read or write data from/to port.
Architecture and instruction set. Microcontroller Core Features:  Operating speed: DC - 20 MHz clock input DC ns instruction cycle Up to 8K x.
Microcontroller Intel 8051 [I/O Ports]. Pin out of the 8051 –40 pin package –32 pins are used for the 4 ports. –V CC / V SS –ALE Address Latch Enable.
Presented by Sadhish Prabhu
Department of Electronic & Electrical Engineering Template program. Input / Output (IO) ● Template program. ● Introduction to IO ● Setting up for IO ●
Features of the PIC18 microcontroller - 8-bit CPU - 2 MB program memory space (internal 32KB to 128KB) bytes to 1KB of data EEPROM - Up to 4096 bytes.
Department of Electronic & Electrical Engineering Lecture 2 ● Introduction to IO ● Using a subroutine ● Driving a 7seg display.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
Embedded System Spring, 2011 Lecture 11: Bank Switching Eng. Wazen M. Shbair.
Chapter Microcontroller
Interrupts ELEC 330 Digital Systems Engineering Dr. Ron Hayne
Interrupts ELEC 330 Digital Systems Engineering Dr. Ron Hayne Images Courtesy of Ramesh Gaonkar and Delmar Learning.
Department of Electronic & Electrical Engineering Lecture 3. ● Template program. ● Introduction to IO ● PORTA PORTB TRISA TRISB ● Using a subroutine ●
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
5-2-1 PIC microcontroller. Learning objectives To aid revision, areas that are examinable are identified by a vertical line in the left margin. Where.
I/O PORTS. General purpose I/O pins can be considered the simplest of peripherals. They allow the PICmicro™ to monitor and control other devices. To add.
16F877A.
Input/Output Ports and Interfacing
Diagram of microprocessor interface with IO devices
INT. TO EMBEDDED SYSTEMS DEVELOPMENT
COMP2121: Microprocessors and Interfacing
Microprocessor Systems Design I
PIC 16F877.
Microprocessor Systems Design I
PIC18 CH. 4.
The PIC uCs PIC Microcontroller and Embedded Systems Muhammad Ali Mazidi, Rolin McKinlay and Danny Causey Eng. Husam Alzaq The Islamic Uni. Of Gaza 11-1.
INSTRUCTION SET.
Figure 2-1. PIC WREG and ALU Using Literal Value
PIC18 Interrupt Programming
CHAPTER 4 I/O PORT PROGRAMMING.
Presentation transcript:

Embedded System Spring, 2011 Lecture 9: I/O Programming Eng. Wazen M. Shbair

2 IUG- Embedded System Today’s Lecture  I/O Port Programming in PIC Microcontroller  I/O Bit Manipulation Programming

3 Objective  List all the ports of the PIC18  Describe the dual role of PIC18 pins  Code Assembly to use ports for input or output  Code PIC instructions for I/O handling  Code I/O bit-manipulation Programs for  PIC  Explain the bit addressability of PIC ports

4 I/O Port Programming in PIC18  PIC18 has many ports Depending on the family member Depending on the number of pins on the chip  Each port can be configured as input or output.  Bidirectional port Each port has some other functions Such as timer, ADC, interrupts and serial communication.  Some ports have 8 bits, while others have not

5 I/O Port Programming in PIC18

6

7 I/O SFR  Each port has three registers for its operation: TRIS register (Data Direction register)  If the corresponding bit is 0  Output  If the corresponding bit is 1  Input PORT register (reads the levels on the pins of the device) LAT register (output latch)  The Data Latch (LAT) register is useful for read- modify-write operations on the value that the I/O are driving.

8 I/O SFR  PICC18F458 has 5 Ports  Upon reset, all ports are configured as input.  TRISx register has 0FFH

9 Port A  PORTA is a 7-bit wide, bidirectional port.  The corresponding Data Direction register is TRISA. Setting a TRISA bit (= 1) will make the corresponding PORTA pin an input Clearing a TRISA bit (= 0) will make the corresponding PORTA pin an output  On a Power-on Reset, these pins are configured as inputs and read as ‘0’

10 Example: Port A as Output

11 Example: Port A as Input

12 PORT B, PORT C, PORT D and PORT E  PORTB is 8 pins  PORTC is 8 pins  PORTD is 8 pins  PORTE is 3 pins

13 Read followed by write operation  Be carful Don’t have two I/O operations one right after the others.  Data Dependency A NOP is needed to make that data is written in the WREG before it read for outputting to PortB

14

15 I/O Bit Manipulation Programming  I/O ports and bit-addressability  Monitoring a single bit  Reading a single bit

16 I/O ports and bit addressability

17 Bit Oriented Instruction for PIC18

18 BSF (bit set fileReg)  Used to set HIGH for a single bit in fileReg  The Syntax : BSF fileReg, bit_num

19

20 BCF(bit clear fileReg)  Used to clear a sigle bit of given fileReg  The Syntax: BCF fileReg, bit_number

21

22 Checking an input pin  To make decisions base on the status of a given bit in the file register, we use: BTFSC (bit test fileReg skip if clear) BTFSS (bit test fileReg skip if set)  These single-bit instruction allow to monitor a single bit and make decision whether it is 0 or 1.

23

24 Reading a single bit  We can use bit test instruction to read the status of the single bit and send it to another bit of save it

25

26 Reading input pins VS. LATx port  There are two possibilities to read port’s value Through reading the status of the input pin Through reading the internal latch of the LAT register. Some instructions do that  The action is The instruction read the latch instead of the pin Execute the instruction Write back the result to the Latch The data on the pins are changed only if the TRISx The PIC uCs bits are cleared.

27 Reading input pins VS. LATx port

28 IUG- Embedded System28 References  Jie Hu, ECE692 Embedded Computing Systems, Fall  PIC Microcontroller And Embedded Systems: using Assembly and C for PIC 18, M. Mazidi, R. McKinlay and D. Causey, Prentice Fall,  Eng. Husam Alzaq, Embedded System Course, IUG, 2010