Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

AVR ATMega32 Architecture

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Introduction to Atmel AVR

• Atmel Corporation is a manufacturer of semiconductors, founded in


1984.

• Atmel introduced the first 8-bit flash microcontroller in 1993, based on


the 8051 core.

• In 1996, a design office was started in Trondheim, Norway, to work on


the AVR series of products.

• Its products include microcontrollers (including 8051 derivatives and


AT91SAM and AT91CAP ARM-based micros), and its own Atmel AVR
and AVR32 architectures.
Introduction to Atmel AVR
• The AVR architecture was conceived by two students at the Norwegian
Institute of Technology (NTH) Alf-Egil Bogen and Vegard Wollan.
• The AVR is a modified Harvard architecture 8-bit RISC single chip
microcontroller which was developed by Atmel in 1996. The AVR was one of
the first microcontroller families to use on-chip flash memory for program
storage, as opposed to one-time programmable ROM, EPROM, or EEPROM
used by other microcontrollers at the time.
• The AVR is a modified Harvard architecture machine where program and data
is stored in separate physical memory systems that appear in different
address spaces, but having the ability to read data items from program
memory using special instructions.
AVR different groups

• Classic AVR
– e.g. AT90S2313, AT90S4433
• Mega
– e.g. ATmega8, ATmega32, ATmega128
• Tiny
– e.g. ATtiny13, ATtiny25
• Special Purpose AVR
– e.g. AT90PWM216,AT90USB1287
Let’s get familiar with the AVR part numbers

ATmega128

Atmel group
Flash
=128K

ATtiny44 AT90S4433

Atmel
Tiny Flash =4K Atmel Classi
Flash =4K
group c
group
ATMega32 Pin out & Descriptions

Port B
Clears all the
registers
Provides and
supply
Port A
restart
voltagethe
to the Reference voltage
These
chip. Itpins
execution arebe
of
should for ADC
Supply voltage for
used to connect
program
connected to +5 ADC and portA.
external crystal or
Connect it to VCC
RC oscillator

Port C
Port D
ATMega32 Pin out & Descriptions
ATMega32 Pin out & Descriptions
ATMega32 Pin out & Descriptions
Digital IO is the most fundamental mode of connecting a MCU to external world.
The interface is done using what is called a PORT. A port is the point where
internal data from MCU chip comes out or external data goes in. They are
present is form of PINs of the IC. Most of the PINs are dedicated to this function
and other pins are used for power supply, clock source etc . ATMega32 ports are
named PORT A, PORT B, PORT C and PORT D.
ATMega32 Pin out & Descriptions

Mega32/Mega16
(XCK/T0) PB0 PA0 (ADC0)
(T1) PB1 PA1 (ADC1)
(INT2/AIN0) PB2 PA2 (ADC2)
(OC0/AIN1) PB3 PA3 (ADC3)
(SS) PB4 PA4 (ADC4)
(MOSI) PB5 PA5 (ADC5)
(MISO) PB6 PA6 (ADC6)
(SCK) PB7 PA7 (ADC7)
PINA

PORTB
DDRB
PINB
RESET DDRA AREF
PORTA
VCC AGND
PORTC
GND DDRC AVCC
PINC
XTAL2 PC7 (TOSC2)
XTAL1 PC6 (TOSC1)
(RXD) PD0 PC5 (TDI)
(TXD) PD1 PC4 (TDO)
(INT0) PD2 PC3 (TMS)
(INT1) PD3 PC2 (TCK)
(OC1B) PD4 PC1 (SDA)
(OC1A) PD5 PC0 (SCL)
(ICP) PD6 PD7 (OC2)
ATMega32 Pin out & Descriptions
ATMega32 Pin out & Descriptions
Defining a pin as either Input or Output – The DDRx Registers

LDI R20,0xFF ;R20 = 0b01110101 (binary)


OUT PORTx,R20 ;PORTA = R20
OUT DDRx,R20 ;DDRA = R20

DDRx = 0b01110101; /* Configuring I/O pins of portb */


AVR Architecture
ATMega32 Architecture
• Native data size is 8 bits (1
byte).
• Uses 16-bit data addressing
allowing it to address 216 =
65536 unique addresses.
• Has three separate on-chip
memories
• 2KB SRAM
• 8 bits wide used
to store data
• 1KB EEPROM
• 8 bits wide used
for persistent
data storage
• 32KB Flash
• 16 bits wide
used to store
program code
• I/O ports A-D
• Digital input/output
• Analog input
• Serial/Parallel
• Pulse accumulator
In Next class we will try to discus about:
 Assembly language Programming with ATmega32 Instruction Set
 Programming in C to Interface peripherals, Interrupts, ISR and
Timers
What is Assembly Language?

 It is a type of low-level programming language that is intended to


communicate directly with computer’s hardware.
 It is a low-level, human readable programming language in which
each assembly instruction relates to a computer machine code
instruction.
 Programmer can write the assemble code to access registers and
retrieve the memory address of pointers & values.
 It provides programmers with direct control, enabling them to
access the low LL components of a computer system such as CPU,
memory, I/O.
 This makes it a valuable language for low-level programming tasks
such as writing device drives and real time and embedded system.
 It is highly optimized for performance(fast program execution).
 The process of assembling involves converting/ translate the
mnemonic codes into their binary equivalents by using assembler.
 Assembly language use commands which is an instruction that tells
the assembler what action to take.
 Assembly language commands frequently use abbreviations to keep
the terminology short by using self-descriptive abbreviations such
as ADD for addition and MOV for data transfer.
Assembly language Programming with ATmega32 Instruction Set

What is Instruction Set?


 Instruction is like a command to be executed by
Control Unit within the microprocessor or
microcontroller.
 Instruction is usually grouped by 4 types:
 Data transfer (ex. MOV)
 Arithmetic and Logic (ex. ADD, SUB,MUL…)
 Control Transfer (ex. JMP)
Cont.

 Every microprocessor has their own instruction.


 Instruction set is the list of instruction understood
only by a specific microprocessor.
Cont.
Cont.
Cont.
 LDI (Load Immediate): writes a constant into a register.
example:- LDI R16,0xFF (writes FFH into register 16)
 OUT: writes data from register to a specific I/O port.
ex. OUT DDRA,R16 (writes data from register 16 to port A)
 IN: reads data from a specific I/O port into a register.
example. IN R16, PORTA (reads data from port A and stores
it to register 16).
Cont.
 SBI (Set bit in I/O): set (put into High Voltage) a bit in I/O port
example:- SBI PORTA,0 (set bit 0 in port A to High Voltage)
 CBI (Clear bit in I/O): unset (put into Low Voltage) a bit in I/O
port
example:- CBI PORTA,1 (set bit 1 in port A to Low Voltage)
 SBIS (Skip if bit in I/O is set): skip 1 instruction below if a
specific bit in I/O port is set (High Voltage)
example:- SBIS PORTA,2 RJMP RPT
“RJMP RPT” will be skipped if bit 2 in port A is High Voltage
Cont.
 SBIC (Skip if bit in I/O is cleared): skip 1 instruction
below if a specific bit in I/O port is unset (Low Voltage)
example:- SBIC PORTA,2 RJMP RPT
“RJMP RPT” will be skipped if bit 2 in port A is Low
Voltage.
Arithmetic Instruction
No_ Instruction Operand Description Operation Flags Clock

1 ADD Rd, Rr Adding two Rd<-Rd+Rr Z,C,N,V,H 1


register
2 ADDC Rd, Rr Adding two Rd<-Rd+Rr+C Z,C,N,V,H 1
Register with carry
3 ADIW Rd1, k Add immediate to Rdh<-Rd1+k Z,C,N,V,S 2
word
4 SUB Rd, Rr Subtracting two Rd<-Rd-Rr Z,C,N,V,H 1
registers
5 SUBI Rd, k Subtract constant Rd<-Rd-k Z,C,N,V,H 1
from register
6 SBC Rd, Rr Subtract with carry Rd<-Rd-Rr-C Z,C,N,V,H 1
two registers
Cont.
Data transfer

You might also like