You are on page 1of 14

Lab 3.

I/O Ports

Professor: Oleg Nepomnuashchiy


Assistant: Svetlana Leshchenko
What the I/O Ports is?
An I/O port is a socket that a cable is plugged into. The port connects the CPU to a peripheral device via a hardware
interface or to the network via a network interface.

AVR Microcontroller

PORT A
PORT B

PORT C
PORT D 2
Arrangement of elements in STK500

3
Synchronization when reading an externally applied pin value

 tpd,max - maximum propagation delays


 tpd,min - minimum propagation delays
4
Synchronization when reading a software assigned pin value

 tpd - delay in one system clock period


5
General Digital I/O

6
Port Implementation
Input Output

Assume that the address of output port is 9CH

7
Description of general purpose LEDs

 8 yellow LEDs
 Logical “1” – switch on
 Logical “0” – switch off

Valid target voltage range is


1.8V < VTG < 6.0V

8
Implementation of Switches and Switch
Headers

 Logical “1” on SWn – not pressed


 Logical “0” on SWn – pressed

Valid target voltage range is


1.8V < VTG < 6.0V

9
Example 1. Switch on the light

10
Example 2. Handle the pressed button

11
Lab 3. The task
Purpose of work: studying the operations of working with I / O ports, the use of subroutines.

Develop a program in which to implement button click handling. Program processing for each
individual button for action in accordance with the task variant. The result of the program
execution should be displayed on the LEDs.

12
Lab 3. The forms
Forms BUTTON 1 BUTTON 2 BUTTON 3 BUTTON 4 bit string

1 Shift to the left Increment Decrement Shift to the right 01010101


2 Shift to the right Shift to the left Increment Decrement 11001100
3 Decrement Shift to the right Shift to the left Increment 10101010
4 Shift to the right Decrement Increment Shift to the left 00110011
5 Decrement Increment Shift to the left Shift to the right 11110000
6 Increment Shift to the left Shift to the right Decrement 00001111
7 Shift to the left Increment Shift to the right Decrement 11000011
8 Decrement Shift to the left Increment Shift to the right 00111100
9 Shift to the right Decrement Shift to the left Increment 00110011
10 Decrement Shift to the right Increment Shift to the left 10101010
11 Shift to the right Increment Shift to the left Decrement 11001100
12 Increment Shift to the left Decrement Shift to the right 01010101
13 Shift to the left Increment Shift to the right Decrement 11100010
14 Shift to the right Shift to the left Increment Decrement 01100110
15 Decrement Shift to the right Shift to the left Increment 10011001
Useful links and reading
1. ATmega32A Datasheet Chapter 13 (pp.56-65)
(https://e.sfu-kras.ru/pluginfile.php/1936311/mod_resource/content/2/ATmega32A-
DataSheet-Complete-DS40002072A.pdf)

14

You might also like