You are on page 1of 12

Microprocessor &

Microcontroller
Courtesy: AVR ATmega8 Datasheet
Unit – III
ATmega8 Microcontroller
Dr. J. Siva
1
Microcontrollers vs Microprocessor
Choosing a Microcontroller
• Word length (ALU size)
• Speed
• Packaging
• On-chip Peripherals
• I/O Pins
• Memory
• Power consumption
• Cost
• Upgarde
• Development tools
AVR CPU core
Features of AVR ATmega8
Pin Configuration of AVR ATmega8
ATmega8 – Data Memory Map
ATmega8 – Register file
AVR ATmega8 I/O Ports
• Port B (8-bit): PB7 – PB0
• Port C (7-bit): PC6 – PC0
• Port D (8-bit): PD7 – PD0
• All AVR ports have true Read-Modify-Write functionality when used as
general digital I/O Ports
• All port pins have individually selectable pull-up resistors
• Three I/O memory address locations are allocated for each port, one each
– Data Register : PORTx,
– Data Direction Register : DDRx,
– Pin Register : PINx
• The PIN reg I/O location is read only
• Data Register (PORTx) and the Data Direction Register (DDRx) are
read/writable
• Enabling the alternate function of some of the port pins does not affect
the use of the other pins in the port as general digital I/O
AVR ATmega8 I/O Ports

Similar registers: DDRC, DDRD

•The DDRxn bit in the DDRx Register selects the direction of this
pin.
•If DDRxn is written logic one, Pxn is configured as an output pin.
•If DDRxn is written logic zero, Pxn is configured as an input pin.
AVR ATmega8 I/O Ports

Similar registers: PORTC, PORTD

when the pin is configured as an input pin:


• If PORTxn is written logic one, the pull-up resistor is activated.
• If PORTxn is written logic zero, the pull-up resistor is off

when the pin is configured as an output pin:


• If PORTxn is written logic one, the port pin is driven high (one).
• If PORTxn is written logic zero, the port pin is driven low (zero).

Always keep the internal pull-up enabled for digital I/P pins.
AVR ATmega8 I/O Ports

Similar registers: PINC, PIND

•Independent of the setting of Data Direction bit DDxn, the port


pin can be read through the PINxn Register Bit.

You might also like