MICROCONTROLLER
ATmega32
Saad Ahmed
BE(E)
What is Microcontroller ?
• A microcontroller is a small computer on a single
integrated circuit containing a processor core, memory,
and programmable input/output peripherals.
Types of Microcontrollers
AT mega 32
• ATMEL AVR chips pack lots of power (1MIPS/MHz, clocks up to 16MHz)
and space (up to 128K of flash program memory and 4K of EEPROM and
SRAM) at low prices.
• HLL Support, like C, helps increase reuse and reduce turn-around/debug
time/headaches.
• In-System Programmable flash--can easily program chips, even while in-
circuit.
• Many peripherals: a whole bunch of internal and external interrupt sources
and peripherals are available on a wide range of de-vices (timers, UARTs,
ADC, watchdog, etc.).
• 32 registers: The 32 working registers (all directly usable by the ALU) help
keep performance snappy, reducing the use of time-consuming RAM
access.
Basic Architecture
Pin Configuration
Instruction Set
Application(Stepper Motor)
Source code
#include<avr/io.h>
#include<util/delay.h>
void main()
{
DDRB=0b00001111;
while(1)
{
if(PIND==0b00000001)
{
PORTB=0b00000001;
_delay_ms(10);
PORTB=0b00000011;
_delay_ms(10);
PORTB=0b00000010;
_delay_ms(10);
PORTB=0b00000110;
_delay_ms(10);
PORTB=0b00000100;
_delay_ms(10);
PORTB=0b00001100;
_delay_ms(10);
PORTB=0b00001000;
_delay_ms(10);
PORTB=0b00001001;
_delay_ms(10);
}
Cont…
if(PIND==0b00000010)
{
PORTB=0b00001000;
_delay_ms(10);
PORTB=0b00001100;
_delay_ms(10);
PORTB=0b00000100;
_delay_ms(10);
PORTB=0b00000110;
_delay_ms(10);
PORTB=0b00000010;
_delay_ms(10);
PORTB=0b00000011;
_delay_ms(10);
PORTB=0b00000001;
_delay_ms(10);
PORTB=0b00001001;
_delay_ms(10);
}
DDRD=0b00010000;
}
}
Thank you

ATmega32