Input/Output (I/O) Ports: Sistemas Embebidos Oscar Acevedo, PHD

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Input/Output (I/O) Ports

Sistemas Embebidos
Oscar Acevedo, PhD
I/O Ports

• They are used for binary input-output data transfer between the μC and external digital
circuits

• I/O bits are usually grouped in 8-bit sets, called ports

• For each I/O bit there is a physical pin (not always)

• Each I/O bit can be configured individually as input or output

• ATMega328 has 3 8-bit ports called PortB, PortC and PortD


I/O Ports

• All port pins have individually selectable pull-up resistors

• I/O memory address locations are allocated for each port


• Data Register PORTx
• Data Direction Register DDRx
• Port Input Pins PINx
Basic I/O Structure
I/O Ports

• If some pins are unused, it is recommended to ensure that these pins have a defined
level

• Most port pins are multiplexed with alternate functions for the peripheral features on the
device
ATMega328 Port Distribution
Digital I/O Ports Usage

• Use ATMega328 registers:


• DDRD = B00001111; sets portD bits 0-3 as outputs and bits 4-7 as inputs
• PORTD = B00001111; writes portD
• Y= PIND; reads portD and stores in variable Y

• Be careful not to configure hardwired inputs as output and vice versa


Fin de la presentación

You might also like