Lab Manual 1
Lab Manual 1
EC Department
Sub: Microprocessor and Microcontroller (3141008)
List of Experiment / Index
The AVR microcontrollers are based on the advanced RISC (Reduced Instruction Set Computer)
architecture. ATmega32 is a low power CMOS 8-bit microcontroller based on the AVR enhanced
RISC architecture. AVR can execute 1 million instructions per second if cycle frequency is 1MHz.
It is also called Microcontroller with Harvard architecture. In Harvard architecture, data bus and
address bus are separate. Thus a greater flow of data is possible through the central processing
unit, and of course, a greater speed of work.
ATmega8 8K 1K 0.5K 23 8 3
ATmega16 16K 1K 0.5K 32 8 3
ATmega32 32K 2K 1K 32 8 3
ATmega64 64K 4K 2K 54 8 4
ATmega128 128K 8K 4K 86 16 6
Key Features
32 x 8 general working purpose registers.
32K bytes of in system self programmable flash program memory
2K bytes of internal SRAM
1024 bytes EEPROM
Available in 40 pin DIP, 44 lead QTFP, 44-pad QFN/MLF
32 programmable I/O lines
8 Channel, 10 bit ADC
Two 8-bit timers/counters with separate prescalers and compare modes
One 16-bit timer/counter with separate prescaler, compare mode and capture mode.
4 PWM channels
In system programming by on-chip boot program
Programmable watch dog timer with separate on-chip oscillator.
Programmable serial USART
Master/slave SPI serial interface
AREF AREF is the analog reference pin for the A/D converter.
Memory Organization:
The Atmega32 memory is divided into two memory spaces: Program Memory space and the
data memory space.
Stack:
A stack is a consecutive block of data memory allocated by the programmer. This block of memory
can be use both by the microcontroller internal control as well as the programmer to store data
temporarily. The stack operates with a Last In First Out (LIFO) mechanism, i.e the last thing store
on the stack is the first thing to be retrieved from the stack.
Stack Pointer:
The stack pointer is basically a register or registers that holds either "the memory address of the
last location on that stack where data was stored" or "the memory address of the next available
location on the stack to store data." The definition of the stack pointer depends on the design of
the microcontroller
A timer is a simple counter! The input clock of microcontroller and operation of the timer is
independent of the program execution. All the Atmel microcontrollers have Timers as an inbuilt
peripheral. The 8-bit counters can count to 255 whilst the 16- bit counter can count to 65,536.
Timers can run asynchronous to the main AVR core hence timers are totally independent of CPU.
A timer is usually specified by the maximum value to which it can count, beyond which it
overflows and resets to zero. Speed of the counting can be controlled by varying the speed of clock
input to it. As we know, all the components of a microcontroller unit (MCU) are some way
connected to the central processing unit (CPU) and some registers, to share information between
them.
TCNT (Timer/Counter Register): when you reset microcontroller, TCNT becomes zero. It
counts up with each pulse. The content of timer/ counter may be excess using TCNT register.
TCCR (Timer/Counter Control Register): It is used to set mode of operation for time.
OCR (output compare register): The content of OCR register is compared with content of TCNT
register, and when they are equal, OCF will become zero.
2. Interrupts
AVR microcontroller has multiple interrupts sources. The ATmaga32 interrupts are as below:-
1. Reset
4. Timer1 compare Match A (T1 COMPA), Timer1 Compare Match B, Timer2 compare
(T1 COMPB) Match (T2COMP) and Timer0 compare Match(T0COMP)
6. SPI interrupts
7. ADC interrupt-ADIF
The USART stands for universal synchronous and asynchronous receiver and transmitter. It is a
serial communication of two protocols. This protocol is used for transmitting and receiving the
data bit by bit with respect to clock pulses on a single wire.
The registers that are responsible for serial communication and handling the USART
4. UCSRV register
5. UCSRC register
Experiment No: 2
Aim: Write an assembly language program for addition and subtraction for 8085
Microprocessor
1. Write a program to load accumulator from 4000h memory location
2. Write a program to store the FF h in memory location 5000h.
3. Write a program to add F0 h and 12 h. Store result in memory location 4000h and 4001h.
4. Write a program to subtract AA h and BB h. Store result in memory location 4000h and
4001h.
Experiment No:3
Aim: Write Assembly Language Program for data transfer operation.
1. Write a program to load 30H and 97H into memory location 0105H and 0106H.
2. Write a program to load 55H into memory location from 300H to 380H.
3. Write a program to transfer 55H into port B.
4. Write an assembly language program to copy data from memory location 0x68 to PORT
C.
5. Write a program to transfer data from R20 register to PORT D register.
Experiment No:4
Aim: Write Assembly Language Program for addition and subtraction operations.
1. Write a program to add 35H and 25H and store the result in R20 register.
2. Write a program to add 759AH and 39H and store the result in R24 and R25 register.
3. Write a program to add following numbers and save result in R20 register(25H,19H,12H).
4. Write a program to add 759AH to BC48H and save the result to R20and R24 register.
5. Write a program to subtract BC48H from 7F9AH and stote the result in R20 and R21
register.
Experiment No:5
Aim: Write Assembly Language Program for multiplication and division operations.
1. Write a program to perform multiplication operation of 77H and 39H.
2. Write a program to perform division operation of 64H and 04H.
Experiment No:6
Aim: To write assembly language program for logical operations.
6
Experiment No:12
Components required:
Arduino UNO
LED
Resistor
Circuit:
Program code:
/* To blink an LED*/
void setup()
{
pinMode(LED_pin,OUTPUT); //initialize digital pin 11 as output
}
void loop()
{
digitalWrite(LED_pin,HIGH); // make LED_pin HIGH
delay(1000); // wait for a second
digitalWrite(LED_pin,LOW); // make LED_pin LOW
delay(1000); // wait for a second
}
Experiment No:13
Components required:
Circuit:
Connections:
Program code:
/*
Demonstrates the use a 16x2 LCD display.
This sketch prints "VISHWAKARMA GOVT ENGG COLLEGE" to the
LCD
*/
void setup()
{
// set up the LCD's number of columns and
rows: lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("VISHWAKARMA
GOVT");
// set the cursor to column 0 and row 1 of the
LCD. lcd.setCursor(0,1);
lcd.print("ENGG COLLEGE");
}
void loop()
{
Output: