Академический Документы
Профессиональный Документы
Культура Документы
MICROPROCESSOR SYSTEM
ASSIGNMENT 1
5/24/2014
GROUP MEMBERS:
MOHD NIZAM BIN SAMAD (SX111612EES04)
AZALELA BINTI PUNARI (SX095332EED04)
ZAIREY LEE (SX110611EES04)
SEE 3223
INTRODUCTION
ATmega32 is very much similar to ATmega16 microcontroller with certain differences which
are discussed below. ATmega32 is an 8-bit high performance microcontroller of Atmels
Mega AVR family. Atmega32 is based on enhanced RISC (Reduced Instruction Set
Computing) architecture with 131 powerful instructions. Most of the instructions execute in
one machine cycle. Atmega32 can work on a maximum frequency of 16MHz.
The differences between ATmega32 and ATmega16 can be summarized as follows:
1. ATmega32 has 32 KB programmable flash memory, static RAM of 2 KB and
EEPROM of 1 KB. The endurance cycle of flash memory and EEPROM is 10,000
and 100,000, respectively.
RAM
Flash
EEPROM
ATmega32
2 KB
32 KB
1 KB
ATmega16
1 KB
16 KB
512 bytes
2. The Bootloader area, the NRWW section starts at word 0x3800 in ATmega32 while in
ATmega16 it starts at 0x1C00.
3. ATmega32 has a different interrupt table, the table given below shows the difference.
More details can be obtained from the respective datasheets.
SEE 3223
Vector #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
ATmega32
Reset
INT0
INT1
INT2
Timer2 COMP
Timer2 OVF
Timer1 CAPT
Timer1 COMPA
Timer1 COMPB
Timer1 OVF
Timer0 COMP
Timer0 OVF
SPI, STC
USART, RXC
USART, UDRE
USART, TXC
ADC
EE_RDY
ANA_COMP
TWI
SPM_RDY
ATmega16
Reset
INT0
INT1
Timer2 COMP
Timer2 OVF
Timer1 CAPT
Timer1 COMPA
Timer1 COMPB
Timer1 OVF
Timer0 OVF
SPI, STC
USART, RXC
USART, UDRE
USART, TXC
ADC
EE_RDY
ANA_COMP
TWI
INT2
Timer0 COMP
SPM_RDY
4.
In MCUCR register, the SM2 and SE bits are swapped, i.e., the SM2 bit is bit7 and SE
bit is bit6 in MCUCR register in ATmega32.
Pin Diagram
SEE 3223
Pin Description:
Pin No.
Pin name
Description
Alternate Function
(XCK/T0)
PB0
(T1) PB1
(INT2/AIN0)
I/O PORTB, Pin 2
PB2
(OC0/AIN1)
PB3
(SS) PB4
(MOSI) PB5
(MISO) PB6
(SCK) PB7
RESET
10
Vcc
11
GND
GROUND
12
XTAL2
13
XTAL1
14
(RXD) PD0
15
(TXD) PD1
16
(INT0) PD2
17
(INT1) PD3
18
(OC1B) PD4
19
20
(ICP) PD6
21
PD7 (OC2)
22
PC0 (SCL)
23
PC1 (SDA)
24
PC2 (TCK)
25
PC3 (TMS)
26
PC4 (TDO)
TWI Interface
JTAG Interface
SEE 3223
27
28
29
PC5 (TDI)
PC6
(TOSC1)
PC7
(TOSC2)
30
AVcc
31
GND
GROUND
32
AREF
33
ADC Channel 7
34
ADC Channel 6
35
ADC Channel 5
36
ADC Channel 4
37
ADC Channel 3
38
ADC Channel 2
39
ADC Channel 1
40
ADC Channel 0
SEE 3223
SCHEMATIC DIAGRAM
SEE 3223
FLOWCHART
start
Set R17 = 12
Set R18 = A1
Set R19 = D3
Decrease R17
Decrease R18
Decrease R19
YES
R17 0
R18 0
R19 0
NO
End
SEE 3223
ldi temp,low(ramend)
out spl,temp
ldi temp,high(ramend)
out sph,temp
ldi
temp,0b11111111
out
ddra,temp
ldi
putar:
000008 bb0b
000009 d002
00000a 9507
00000b cffc
rjmp
temp,led
sec
out
rcall
ror
putar
porta,temp
;sent data to porta (LED)
tunda
;delay 0.25 s
temp
;rotate one bit right through carry
;jump to label putar
; =============================
; delay loop generator
; 1843200 cycles:
; for freq 8MHz
; delay until 0.25 s
7
SEE 3223
SEE 3223
Simulation
Circuit simulation was done by using Proteus 8.0. The main purpose of this simulation was to ensure
that the circuit can be run as required.
SEE 3223
The screenshot below shows the interface for Proteus Software.
Setting up the ATmega 32 by using .hex file. This setting also allows us to introduce the crystal
oscillator frequency.
10
SEE 3223
Process simulation is in progress. The Blue sign indicated LEDs are in switched ON while the red
sign shows LED off.
CONCLUSION
The compiler AVR Studio version 4.0 can be obtained download FREE from
http://www.atmel.com. Program's start with some kind of declaration, we accidentally enter
information in the listing program to facilitate learning directly from the listing, note the
instructions that begin with '.' Is a directive of the AVR Studio, AVR microcontroller
assembly instructions instead:
;-----------------------------------------;LED running light
;untuk Atmel AVR ATMega32
;frekuensi kristal 8MHz
;-----------------------------------------.nolist ;bahagian ini
.include "m32def.inc"
.list
; list
Remember the file "m32def.inc" we include (directive. Include) because it will be utilized in
our program ATMega32 library, simply do not ask to be included in the results of the LIST
file (the result of compiling the program) using the directive. Nolist and. Lists.
11
SEE 3223
LED variable used to store data that will be released through PORTA, initially filled 0b01111111, 0
means the LED will be lit first. The program begins by declaring a segment of code (. Cseg) and start
address 0 0000 (. Org).
Initialize the program with stack, there is a strong likelihood of congestion on the
program, meaning the program as if struck. If you are using a kind of Proteus 8.0 simulator.
The program will run without error, but when it attempted to program the actual circuit will
stop (stuck). Here are excerpts of the program to initialize the stack at the end of RAM space
(RAMEND).
12
SEE 3223
;-----------port initial--------------------ldi
temp,0b11111111 ;set semua bit register temp
out
ddra,temp
;tuliskan ke register DDRA
Data stored on the variable TEMP (ldi temp, LED), then the newly issued to PORTA
(out porta, temp), can not be directly sent to PORTA. Furthermore, the main program is
written:Repetition is done by skipping backward to the labels 'rotate' use rjmp swivel.
The last portion of the program is just about 0:25 seconds delay subroutine (see the complete
program listing) by using the AVR program Loop Delay Generator, as screen shoot shown in
Figure 2.
It uses repetition registers, 0:25 Sec delay would not be exact, but tolerable for any
delay shortly. If we want accurate, use the facilities Timer / Counter on AVR microcontroller
is concerned.
13
SEE 3223
14