0% found this document useful (0 votes)
127 views

AVR-ATMega32-Architecture

rfdhfhdf

Uploaded by

Amanuel Tamirat
Copyright
© © All Rights Reserved
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)
127 views

AVR-ATMega32-Architecture

rfdhfhdf

Uploaded by

Amanuel Tamirat
Copyright
© © All Rights Reserved
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/ 25

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.

• 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 is a modified Harvard architecture 8-bit RISC single chip


microcontroller which was developed by Atmel in 1996.
• 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.
• 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 Classic
Flash =4K
group group
ATMega32 Pin out & Descriptions

Port B
Clears all the Port A
registers supply
Provides and
restart
voltage to the
the chip. Reference voltage
These pins are
execution
It should of
be 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 Port description
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
 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
Data transfer
11/12/2024 25

You might also like