Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

ECEN 3213 Spring 2005 Lab 5: Understanding I/O Ports on the 6811 Microcontroller, Lab Reports of Electrical and Electronics Engineering

A lab handout for ecen 3213 spring 2005 students, focusing on gaining familiarity with the 6811 microcontroller's i/o ports. It covers memory-mapped i/o, input and output ports, bidirectional ports, and bit-oriented instructions. Students are expected to write assembly code to monitor input switches and control led outputs.

Typology: Lab Reports

Pre 2010

Uploaded on 03/19/2009

koofers-user-hr8
koofers-user-hr8 🇺🇸

10 documents

1 / 4

Toggle sidebar

Related documents


Partial preview of the text

Download ECEN 3213 Spring 2005 Lab 5: Understanding I/O Ports on the 6811 Microcontroller and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity! ECEN 3213 Spring 2005 Lab 5 Due in Lab Section, Feb. 21, 23 Objective. Gain familiarity with 6811 I/O ports. Discussion. If you look through the TExaS help menu for information about input and output (I/O), you will not find anything. There are no I/O instructions for the 6811. The 6811 uses memory mapped I/O as described in sec. 1.1.3 of the text. The I/O ports correspond to special memory locations that can be accessed with normal load/store instructions. Alter- natively, some processors, such as the Intel Pentium, do not use memory address locations for I/O. Instead, they have special instructions to access the I/O ports. A block diagram of the 6811 I/O ports is shown in fig. 1.28 on p. 24 of the text. When connecting devices to the I/O ports, you must use one of the valid pin names shown in this diagram. The memory addresses assigned to each port are listed in the file C:\Program Files\Valvano\MC6811\port11.rtf if you have used the default installation of the TExaS program. Input Ports. An input port provides bits of data from an external device to the computer. Ordinary load instructions are used to get the data. For example, PORTE equ $100A lda PORTE reads (loads) port E (always input) and puts the result into the a register. It makes no sense to write (store) to an input port. If you attempt to do so, the write will have no effect. Output Ports. An output port allows the computer to send bits of data to an external device. Ordinary store instructions are used to send the data. For example, PORTB equ $1004 lda #$0A sta PORTB writes (stores) the value in the a register ($0A) into port B (always output). The hardware at the output port remembers what has been written into it and keeps outputting this value until the computer writes a new value into the output port. You can read (load) the value that the output port is sending out lda PORTB reads the current output from port BECEN 3213 Spring 2005 Lab 5 January 27, 2005 page 1 of 4 Bi-Directional Ports. To make the hardware more flexible for different applications, bi- directional ports allow the programmer to specify which pins in which ports are to be inputs or outputs. The direction of a particular pin is specified by writing a 0 for input or a 1 for output into a data direction port. For example, PORTC equ $1003 DDRC equ $1007 PORTD equ $1008 DDRD equ $1009 lda #%10011111 sta DDRC sets PC5, PC6 as inputs, rest as outputs lda #%10000010 sta DDRD sets PD7, PD1 as outputs, rest as inputs lda #%00000010 sta PORTD sets PD7 to 0, PD1 to 1, writes to inputs ignored lda PORTD reads 0bbbbb1b where b-bits are from input device Bit Oriented Instructions. The instructions we have used so far have put binary bits together to represent multi-bit binary numbers. The pins on an I/O port are usually read/written independently of other pins on the same port. The 6811 has bit oriented instructions that make it easier to manip- ulate individual bits. The logic instructions fall into this category. The logic functions are defined by representing true as 1 and false as 0. This gives the following truth tables for the “and”, “or” and “eor” logic instructions respectively. U V U&V U|V U^V 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 Logic instructions can be used to “mask” the effects of writes to output ports so that only the desired bits are changed. The following example uses a logical “or” to force certain bits to 1, a logical “and” to force others to 0 and a logical “exclusive or” to toggle bits while leaving the remaining bits unchanged. start lda PORTB get old values for port B ora #%00000010 force 1 into PB1 anda #%01110111 force 0 into PB7 and PB3 eora #%00100000 toggle PB5 sta PORTB write new values to PB7, PB5, PB3, PB1 only Alternatively, the 6811 has special bit set (bset) and bit clear (bclr) instructions to set or clear individual bits without changing others. start bset PORTB,#%00000010 force 1 into PB1 bclr PORTB,#%10001000 force 0 into PB7 and PB3 Logic instructions can also be used to “mask” the effects of unwanted bits during reads from input ports. The following example start lda PORTE read port E anda #%00100000 mask off all bits except bit 5 ECEN 3213 Spring 2005 Lab 5 January 27, 2005 page 2 of 4
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved