0% found this document useful (0 votes)
62 views7 pages

CH 7

This document provides an overview of the Atmel AVR microcontroller, specifically the ATmega16. It discusses the AVR's RISC architecture, instruction set, memory components, I/O ports, timers, serial communication interfaces, analog-to-digital converter, and interrupts. Programming the AVR microcontroller involves using the C programming language to directly control its hardware components and peripherals.

Uploaded by

Parvez Haq
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)
62 views7 pages

CH 7

This document provides an overview of the Atmel AVR microcontroller, specifically the ATmega16. It discusses the AVR's RISC architecture, instruction set, memory components, I/O ports, timers, serial communication interfaces, analog-to-digital converter, and interrupts. Programming the AVR microcontroller involves using the C programming language to directly control its hardware components and peripherals.

Uploaded by

Parvez Haq
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/ 7

Lecture material taken from: 2102440 Introduction to Microprocessors Chapter 7 The AVR Microcontroller

1
2102440 Introduction to Microprocessors

Atmel AVR Microcontroller Primer: Programming and Interfacing, Barrett, S.F. and Pack, D.J., Morgan & Interfacing, Claypool, 2008. Programming and Customizing the AVR microcontroller, Gadre, D.V., McGraw Hill, 2001. microcontroller, Gadre,

Topics
Overview of the RISC architecture of the ATmega16 Memory components Internal subsystems Operating parameters and the ATmega16 features

Why the Atmels AVR microcontroller?


Reduced instruction set computer Harvard Architecture. Mostly fixed-length instruction, load-store memory access, and 32 general-purpose registers. A two-stage instruction pipeline that speeds up execution. Majority of instructions take one clock cycle. Wide variety of on-chip peripherals, including digital I/O, ADC, EEPROM, Timer, UART, RTC timer, pulse width modulator (PWM), etc. Internal program and data memory.
3
2102440 Introduction to Microprocessors

2102440 Introduction to Microprocessors

Why the Atmels AVR microcontroller? (2)


High performance coupled with low power consumption. Outstanding flash memory technology. Wide variety of operating voltages (1.8-5.5 VDC). (1.8Architecture designed for the C language. One set of development tools for the entire AVR line In-system programming, debugging, and verification Incapability. A simple architecture offers a small learning curve to the uninitiated.

Some AVR controllers

2102440 Introduction to Microprocessors

2102440 Introduction to Microprocessors

ATmega16 specifications
Register-based Harvard Architecture 131 RISC-type instructions
Most can be executed in 1 clock cycle.

Pinout ATmega16

32 general purpose 8-bit registers 16 MHz clock speed


Execute 16 million instructions per second.

2102440 Introduction to Microprocessors

2102440 Introduction to Microprocessors

AVR Architecture

ATmega16 Architecture Overview


External connections for power supplies: VCC, GND, AVCC, and AREF External time base input pins to drive its clocks: XTAL1 and XTAL2 Processor reset Four 8-bit ports: PA0-PA7, PB0-PB7, PC0-PC7, and 8PA0PB0PC0PD0-PD7 PD0A timer subsystem An analog-to-digital converter (ADC) analog- toAn interrupt subsystem Memory components A communication subsystem

2102440 Introduction to Microprocessors

2102440 Introduction to Microprocessors

10

Atmel ATmega16 and C Language


We will program the Atmel ATmega16 using C language. The C programming language:
Allow direct control of microcontroller hardware at the register level. Be portable to other microcontrollers in the AVR line.

Nonvolatile and Data Memories


The ATmega16 is equipped with three main memory sections:
Flash electrically erasable programmable read-only memory (EEPROM) Static random access memory (SRAM) Byte addressable EEPROM for data storage

2102440 Introduction to Microprocessors

11

2102440 Introduction to Microprocessors

12

In-System Programmable Flash EEPROM


16K bytes of onboard reprogrammable flash memory.
Memory component is organized into 8K locations with 16 bits at each location.

Byte-Addressable EEPROM
512 bytes of nonvolatile EEPROM. Store and recall variables during program execution. Store data that must be retained during a power failure but might need to be changed periodically such as
system parameters electronic lock combinations automatic garage door electronic unlock sequences

Flash EEPROM is nonvolatile. Bulk programmable flash EEPROM is used to store programs.
It can be erased and programmed as a single unit.

2102440 Introduction to Microprocessors

13

2102440 Introduction to Microprocessors

14

Static Random Access Memory


1000 bytes (actually 1120) of SRAM Its volatile. Can be written to and read from during program execution. During program execution, RAM is used to
store global variables support dynamic memory allocation of variables provide a location for the stack

Port System
Four 8-bit general-purpose digital I/O ports
PORTA, PORTB, PORTC, and PORTD

Each port has three registers associated with it:


Data Register (PORTx) used to write output data to (PORTx) port Data Direction Register (DDRx) used to set a (DDRx) specific port pin to either output (1) or input (0) Input Pin Address (PINx) used to read input data (PINx) from the port

2102440 Introduction to Microprocessors

15

2102440 Introduction to Microprocessors

16

Port-associated Registers

Port Pin Configuration

2102440 Introduction to Microprocessors

17

2102440 Introduction to Microprocessors

18

Port Pin Configuration Program Example

Read Value from Port Pin


The variable used to read the value from the input pins is declared as an unsigned char.

2102440 Introduction to Microprocessors

19

2102440 Introduction to Microprocessors

20

Timing System

Serial Communications
The Universal Synchronous and Asynchronous Serial Receiver and Transmitter (USART)

Internal fixed clock operating frequency of 1, 2, 4, or 8 MHz Two 8-bit timer/counters One 16-bit counter Four pulse width modulated (PWM) channels

The serial USART is used for full duplex (two-way) communication (twobetween a receiver and transmitter. The SPI may be viewed as a synchronous 16-bit shift register with an 8168bit residing in the transmitter and the other 8-bit half residing in the 8receiver. The TWI subsystem allows the system designer to network a number of related devices (microcontroller, transducers, displays, memory storage, etc.) together into a system using a two-wire interconnecting scheme. twoThe TWI allows a maximum of 128 devices to be connected together at the frequencies up to 400 kHz. It allows the device to freely exchange information with other devices in devices the network within a small area.

The serial Peripheral Interface (SPI)

The Two-Wire Serial Interface (TWI) Two-

2102440 Introduction to Microprocessors

21

2102440 Introduction to Microprocessors

22

Analog-to-Digital Converter
An eight-channel ADC subsystem with 10bit resolution. An analog voltage between 0 and 5 V will be encoded into one of 1024 binary (00016 3FF16). A voltage resolution of approximately 4.88 V.

Interrupts
Sometimes, the normal sequence of events must be interrupted to respond to high-priority faults and status highboth inside and outside the microcontroller. When the higher-priority events occur, the highermicrocontroller must temporarily suspend normal operation and execute event specific actions called an interrupt service routine. Once the higher priority event has been serviced, the microcontroller returns and continues processing the normal program. 21 interrupts sources: 3 external interrupt sources and 19 interrupts support vectors.

2102440 Introduction to Microprocessors

23

2102440 Introduction to Microprocessors

24

The Microcontroller Development System

2102440 Introduction to Microprocessors

25

You might also like