0% found this document useful (0 votes)
39 views15 pages

I/O Ports I/O I/O Ports, I/O Mechanism: Microprocessor Interfacing

The document discusses microprocessor interfacing and input/output (I/O) ports. It covers I/O ports, pull-up resistors, port configuration, synchronization when reading external pin values, and I/O code examples. The purpose is to review I/O port functionality and demonstrate code for controlling I/O pins.

Uploaded by

api-27015998
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views15 pages

I/O Ports I/O I/O Ports, I/O Mechanism: Microprocessor Interfacing

The document discusses microprocessor interfacing and input/output (I/O) ports. It covers I/O ports, pull-up resistors, port configuration, synchronization when reading external pin values, and I/O code examples. The purpose is to review I/O port functionality and demonstrate code for controlling I/O pins.

Uploaded by

api-27015998
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

I/O PORTS,

PORTS I/O
MECHANISM
Lecture 05 Microprocessor Interfacing
Review
; Add R1:R0 to R3:R2
ADD r2,r0 ; Add low byte
ADC r3,r1 ; Add with carry high byte
… CISC & RISC
… Von Neumann Architecture & Harvard Architecture
… Register Set
… I t ti SSett
Instruction
… ATMEL AVR ATMega16 Overview
† Non-Volatile and Data Memory
† PORT System
† Peripheral Features
Lecture Objectives
j
… I/O Ports
/
… Pull Up Circuit
… ] // [[Switch On Pull‐UP] 
[[Default]  ] // [[Output], 
p ], Configuration
g
… Synchronization when Reading an Externally /Software 
Applied Pin Value
… I/O Code Examples
… RESET Logic
I/O
/ Ports
I/O
/ Ports
Pull Up
p Resistors
… If PORTxn is written logic one when the pin is configured as an input pin, 
the pull‐up resistor is activated. 
… To switch the pull‐up resistor off, PORTxn has to be written logic zero or 
the pin has to be configured as an output pin. 
… The port pins are tri‐stated when a reset condition becomes active, even 
if no clocks are running
Default Configuration
g
Switch On Pull-Up
p
Port set as Output
p
SFIOR: Special
p Function I/O
/ Register
g
Synchronization when Reading an
E t
Externally
ll AApplied
li d Pi
Pin V
Value
l
Synchronization when Reading a
S ft
Software Assigned
A i d Pi Pin Value
V l
CODE: 01
#include <mega16.h> void main(void)
#include <delay.h> {
unsigned char led=VLED;
#define VLED 0xFE; DDRB = VPOUT ;
PORTB = VPIN ;
#define VRESET 0x00; delay_ms(VDELAY);
#define VSET 0xFF; STEP - 02 while (1)
{
#d f VDELAY
#define 5000
5000; PORTB = led ;
delay_ms(VDELAY);
#define SHFT_BITS 0x01; led << = SHIFT_BITS ;
#define SET_LSB 0x01;; led |= SET_LSB
SET LSB ;

if (led == VPOUT)
led = VLED ;
}
STEP - 01 } STEP - 03
CODE: 02
#include <mega16.h> void main(void)
# l d <delay.h>
#include d l h { while (1)
unsigned char led = VLED ; {
#define VLED 0xFE; DDRB = VSET ; do
PORTB = VRESET ; {
#define
#d fi EOEO_L2R
L2R 0xFE;
0 FE delay_ms(VDELAY); PORTB = led ;
#define EO_R2L 0x7F; delay_ms(VDELAY); delay_ms(VDELAY);
delay_ms(VDELAY); led << = SHIFT_BITS ;
#define VRESET 0x00; led |= SET_LSB ;
#d fi VSET
#define 0 FF
0xFF; STEP - 02 } while (led != EO_R2L) ;
#define VDELAY 1000; do
{
#define
#d fi SHFT_BITS
SHFT BITS 0x01;
0 01 PORTB = led ;
#define SET_LSB 0x01; delay_ms(VDELAY) ;
#define SET_MSB 0x80; led >>= SHIFT_BITS ;
led |= SET_MSB ;
} while (led != EO_L2R) ;
STEP - 01 }
} STEP - 03
Reset Logic
g

You might also like