Micro Controllers Basics
Micro Controllers Basics
Micro Controllers Basics
Vivek Kumar
Abhishek Sharma
Electronics
Programming
Introduction to Microcontrollers
Inside a Microcontroller
Working of Microcontrollers
Applications of Microcontrollers
Writing a program in CV avr
Compiling the program into .HEX file
Upload the program into Microcontroller
Inside a Microcontroller
Working of Microcontrollers
Applications of Microcontrollers
Writing a program in CV avr
Compiling the program into .HEX file
Upload the program into Microcontroller
Like this
But it is much more than that
o Its a mini-computer inside a single IC.
o It has processing power.
o It executes a program just like a computer.
o It has pins, memory, registers, clocks, timers,
interrupts and much more
Features of ATmega 8
Has 28 pins
23 pins for I/O
5 pins reserved
Clock Frequency: 8Mhz
I/O pins divided into 3 groups
Named as Ports.
Three ports B,C and D.
8Kb Flash memory
512Bytes EEPROM
1Kb Internal SRAM
Three inbuilt timers
Two 8-bit
One 16-bit
Operating Voltages
2.7V - 5.5V (ATmega8L)
4.5V - 5.5V (ATmega8)
Maximum programmable Cycles:
10,000 for Flash memory
100,000 for EEPROM
Features of ATmega 16
Has 40 pins
32 pins for I/O
8 pins reserved
Clock Frequency: 16Mhz
I/O pins divided into 4 groups
Named as Ports.
Four ports A,B,C and D.
16Kb Flash memory
512Bytes EEPROM
1Kb Internal SRAM
Three inbuilt timers
Two 8-bit
One 16-bit
Operating Voltages
2.7V - 5.5V (ATmega16L)
4.5V - 5.5V (ATmega16)
Maximum programmable Cycles:
10,000 for Flash memory
100,000 for EEPROM
Next...
Introduction to Microcontrollers
Inside a Microcontroller
Working of Microcontrollers
Applications of Microcontrollers
Writing a program in CV avr
Compiling the program into .HEX file
Upload the program into Microcontroller
Memory Structure
Several type of memories in the C.
o Flash Memory
Memory Structure
Memories
RAM
ROM
Volatile memory
EEPROM
Flash
Memory
Non-Volatile memory
Next...
Introduction to Microcontrollers
Inside a Microcontroller
Working of Microcontrollers
Applications of Microcontrollers
Writing a program in CV avr
Compiling the program into .HEX file
Upload the program into Microcontroller
Registers?
I/O Pins of a Microcontroller are divided generally into
groups of 8 pins called PORT.
Each PORT contains some registers associated with it.
Registers are the links between our code and the
hardware (pins).
They actually are the memory locations inside the C
whose names and sizes are predefined.
Well talk about the 3 registers that control the I/O pins:
DDR, PORT and PIN registers.
Thus, each port (port A,B,C,D) contains these 3 registers.
e.g. port A has registers DDRA, PORTA, PINA;
port B has registers DDRB, PORTB, PINB;
PIN Register
It is also 8-bit register which reads the incoming
voltage on the pins.
PORT Register
Lets Summarize
Registers?
VISUALISATION OF REGISTERS
How do I program my C?
I write my program
on an IDE
I compile my
program
I upload it to my C
My IDE, My CV AVR
The code is written in C language and Atmega
doesnt understand C, so it needs to be converted
to a language that Atmega understands.
Hello.c
Hello.hex
OR ||
AND &&
Bitwise OR |
Bitwise AND &
Bitwise NOT ~
Left Shift <<
Right Shift >>
Basics of C language
if-else block
If(condition)
{
}
else
{
Basics of C language
While
while(condition)
{
Open CV AVR
Scary Syntax?
PORTB.1
This is used to give an output
voltage to B.1 pin
PINC.3
This is used to take input
from C.3 pin
int a = PINC.3;
delay_ms(2000);
This is used to pause code
execution for 2000
milliseconds,
Thats it!