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.

Slides:



Advertisements
Similar presentations
AVR ATMega32 Elementary Input / Output
Advertisements

Introduction to Micro-controllers Anurag Dwivedi.
EXTERNAL COMMUNICATIONS DESIGNING AN EXTERNAL 3 BYTE INTERFACE Mark Neil - Microprocessor Course 1 External Memory & I/O.
TK2633 Introduction to Parallel Data Interfacing DR MASRI AYOB.
Embedded System Spring, 2011 Lecture 9: I/O Programming Eng. Wazen M. Shbair.
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,
Indian Institute of Technology Hyderabad ROBOTICS LINE FOLLOWER HARI KISHAN TANDEY – ES12B1008 DILIP KONDAPARTHI – ES12B1010 SAI KARTIK – CE12B1015.
MICRO-CONTROLLER: A microcontroller is the brain of the robot: These are: 1. Integrated Circuits (ICs) 2. Programmable.
Programming Microcontrollers B. Furman 19MAR2011.
Mark Neil - Microprocessor Course 1 Decoding and Using a 4x4 Keyboard.
Programming the ATmega16
ECE200 – Computer Organization Chapter 8 – Interfacing Processors and Peripherals.
CS-280 Dr. Mark L. Hornick 1 EEPROM Memory Storing, Reading, and Writing.
16.317: Microprocessor System Design I Instructor: Dr. Michael Geiger Spring 2012 Lecture 30: PIC data memory.
Railway Foundation Electronic, Electrical and Processor Engineering.
Basic Computer Organization CH-4 Richard Gomez 6/14/01 Computer Science Quote: John Von Neumann If people do not believe that mathematics is simple, it.
1 COSC 3P92 Cosc 3P92 Week 11 Lecture slides Violence is the last refuge of the incompetent. Isaac Asimov, Salvor Hardin in "Foundation"
Robotics Research Laboratory Louisiana State University.
1-1 SYS Module System Clocks FXTAL BCLK Reset Circuit Reset Conditions Bootstrap Initialization.
Parallel Ports of PC Methods of interfacing Examples.
Introduction to Microcontrollers Shivendu Bhushan Summer Camp ‘13.
Atmega32 Architectural Overview
CS-280 Dr. Mark L. Hornick 1 Parts of a GP Computer (Microcomputer) Contains separate Microprocessor chip Memory/Memory controller MB control chips Peripheral.
Embedded Systems Programming 1 ETEE 3285 Topic HW3: Coding, Compiling, Simulating.
1 EKT 225 MICROCONTROLLER I CHAPTER 3 I/O PORT PROGRAMMING.
AVR Microcontrollers.
C.S. Choy95 COMPUTER ORGANIZATION Logic Design Skill to design digital components JAVA Language Skill to program a computer Computer Organization Skill.
CS-280 Dr. Mark L. Hornick 1 Calling subroutines in assembly And using the Stack.
Parallel Ports, Power Supply and the Clock Oscillator Material to be covered  Parallel I/O ports  Interfacing external switches and LEDs  Clock Oscillator.
Multiplexed External Bus Interface-MEBIV3 By: Prof. Mahendra B. Salunke Asst. Prof., Department of Computer Engg., SITS, Pune-41
Basic I/O Interface A Course in Microprocessor
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.
Lecture 2 Silicon Labs C8051F020 System Overview.
بسمه تعالي AVR Microcontrollers. The ATmega8 Basic Features -1.
Input-Output Organization
AVR Programming: Digital I/O September 10, What is Digital I/O? Digital – A 1 or 0 Input – Data (a voltage) that the microcontroller is reading.
Timers and Interrupts Anurag Dwivedi. Let Us Revise.
CS-280 Dr. Mark L. Hornick 1 Atmel Timer/Counter System Most microcontrollers include some type of timer system Facilitates real-time monitoring and control.
Discussion 2 STATE MACHINES AND AVR ASSEMBLY CMPE 311 / FALL 2015 DR. MOHSENIN & MR. SMITH GTAS: RUTHVIK KUKKAPALLI, AMEY KULKARNI UTAS: JASON KLIMEK,
Programmable Peripheral Interface Parallel port Interface 8255
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.
智慧電子應用設計導論(1/3) Arduino MEGA 2560
Basic I/O Interface Fixed Address Variable Address
EE365 - Microprocessors period 26 10/23/00 D. R. Schertz # Parallel Ports.
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.
Arduino Mega Arduino Mega 2560 Arduino Mega 2560.
CS-280 Dr. Mark L. Hornick 1 Sequential Execution Normally, CPU sequentially executes instructions in a program Subroutine calls are synchronous to the.
Chapter Microcontroller
Mark Neil - Microprocessor Course 1 Decoding and Using a 4x4 Keyboard.
AVR Architecture Prepared By: Avdhesh Soni ( ) Sarthak Patel ( ) Akshay Parekh ( ) Fenil Sachla ( ) Guided.
Introduction to AVR Name : 1) Abhishek Yadav ) Prakash Giri ) Kheni Niral ) Bhadresh Langadiya Branch.
Programming PIC 16F84A in Assembly. PIC16F84 pin-out and required external components.
INTERFACING HARDWARE WITH MICROCONTROLLER GUIDED BY: Prof. ASIF SIR 1. AKSHAY KIRAN 2. DEEP PARIKH 3. JIGAR PATEL 4. TILAK PATEL ,05,D2D06,09.
Embedded Systems Programming (What they do and when / how to use them)
AVR I/O Port Programming
Input/Output Ports and Interfacing
Atmega32 Architectural Overview
AVR ATMEGA 8 MICRO-CONTROLLER
For further information
Chapter 7.2 Computer Architecture
INT. TO EMBEDDED SYSTEMS DEVELOPMENT
COMP2121: Microprocessors and Interfacing
The 8255 Programmable Peripheral Interface
The Arduino Microcontroller: Atmel AVR Atmega 328
I/O Ports in AVR Sepehr Naimi
I/O Ports in AVR Sepehr Naimi
8051 Micro Controller.
CHAPTER 4 I/O PORT PROGRAMMING.
Costas Foudas, Imperial College, Rm: 508, x47590
Presentation transcript:

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 Digital I/O ports, 1 Analog-to-Digital port, 1 Serial port,… The number of ports depends on processor type Each port has a specific fixed address in the I/O address space: 0x00 through 0x3F (0-63) This address space is separate and distinct from the Program and Data address spaces!

Review: Data Memory Map CS-280 Dr. Mark L. Hornick 3 The General-purpose registers, while not SRAM, are assigned the first 32 addresses of the Data Memory address space. The I/O Registers are assigned the next 64 addresses in the Data Memory address space. Note that SREG, SPL, SPH, PORTB, DDRB, etc are all I/O registers Note that all I/O Registers thus have two addresses: one address in the I/O address space and a corresponding address in the Data Memory address space! OUT 0x18, R20 ; same as OUT PORTB, R20 is equivalent to: STS 0x38, R20 ; alternate: STS PORTB+0x20, R20 Note 0x20 offset between I/O and Data addresses for I/O registers

CS-280 Dr. Mark L. Hornick 4 Atmega32 has four digital I/O ports PortA, PortB, PortC, PortD each have 8 pins (Px0 – Px7) Each of these ports is associated with three special-purpose I/O registers, each with their own addresses: DDRx PORTx PINx DDRB, the I/O register (at I/O address 0x17) controls whether the pins on PortB function as input or output: DDRB - Data Direction Register B Each pin of PortB can be configured independently via DDRB Writing 0xff to DDRB configures all pins of PortB to behave as output

CS-280 Dr. Mark L. Hornick 5 Writing to a Port The OUT instruction is used to write a value from a Register to a port OUT PORTB, r25 writes the value of r25 to the PORTB output register (at I/O address 0x18) Each bit in the 8-bit value corresponds to a hw pin of the port Only the pins configured as output will actually be written Be sure to.INCLUDE “m32def.inc”, (which.DEF’s PORTB=0x18): The SBI instruction is used to set a single bit within a port SBI PORTB, 0 sets the value of bit 0 to 1 The CBI instruction is used to reset a single bit within a port CBI PORTB, 0 sets the value of bit 0 to 0

CS-280 Dr. Mark L. Hornick 6 PortB (0x18) is hard-wired to the on-board LEDs Setting a bit (to logical 1) turns the LED on SBI PORTB, 0 ;set bit 0 The associated pin must be configured as an output Note this is similar to OUT PORTB, 0x01 But SBI affects only the single bit, while OUT sets all 8 bits

CS-280 Dr. Mark L. Hornick 7 The digital I/O ports can also be configured to act as INPUT ports The I/O register DDRB controls whether the pins on PortB function as input or output: Each pin of PortB can be configured independently via DDRB Writing 0x00 to DDRB configures all pins of PortB to behave as input Writing 0x0f configures pins 0-3 of PortB as output and pins 4-7 as input

CS-280 Dr. Mark L. Hornick 8 Configuring I/O Portx for digital input 1. First, use DDRx to specify which pins of Portx will function as input and output: LDI temp, 0x0f OUT DDRx, temp ;pins 0-3 output, 4-7 input 2. Next, drive the input pins high (logical 1). If you forget to do this, the pins will assume random voltages (e.g. from static electricity) unless an external voltage is deliberately applied! LDI temp, 0xf0 OUT PORTx, temp ;drive input pins high 3. Finally, you can read the current state of the input pins as the voltages are applied (+5v = logical 1, 0v = logical 0) or as the pin is grounded IN temp, PINx ;read state of input pins

CS-280 Dr. Mark L. Hornick 9 Read from a PINx, not PORTx! The IN instruction is used to read a value from the input pins on a port configured for input: IN R0, PINx; read input pins reads the value of the PORTx INput latch into R0 PINx [the input latch associated with Portx] can only be read, not written Unlike PORTx and DDRx, which can be both read and written