SlideShare a Scribd company logo
1 of 50
Download to read offline
1
00-Let’s get started
By : Mohamed Fawzy
Programming AVR Microcontrollers
© Mohamed F.A.B 2015
Lecture Notes:
2
o Set Your Phone To Vibration Mode.
o Ask any time.
o During labs, Feel Free To Check Any Materials or
Internet.
o Slides are self content.
o Feel Free To Share This Materials With Your Friends.
o Work Hard For Achieving Most Benefits Of This Course.
© Mohamed F.A.B 2015
3
Don't Forget !!!!
© Mohamed F.A.B 2015
Any Expert Was Once A Beginner

4
Agenda.
Lesson (1):
Introduction to micro-controller World.
Lesson (2):
Quick revision for C programming.
Lesson (3):
Installing Our Working Tools.
© Mohamed F.A.B 2015
5
Lesson#1
Lesson (1):
Introduction to micro-controller World.
© Mohamed F.A.B 2015
6
Microcontroller.
o It is a small computer which can control any thing
around the world .
o It basically consists of Microprocessor, Memory(RAM,
ROM, EEPROM), I/O lines and some other peripherals
……….,etc.
DIP Package SMD Package
© Mohamed F.A.B 2015
7
Microcontrollers Vendors.
© Mohamed F.A.B 2015
8
Microcontroller Applications.
© Mohamed F.A.B 2015
9
Microcontroller Vs. Microprocessor.
© Mohamed F.A.B 2015
Microprocessor is a subsystem of Microcontroller system.
10
Internal Components of MC.
© Mohamed F.A.B 2015
11
CPU (Central Processing Unit).
© Mohamed F.A.B 2015
o Instruction Decoder :is a part of the electronics which recognizes
program instructions and runs other circuits on the basis of that.
o Arithmetical Logical Unit (ALU): performs all mathematical and
logical operations upon data.
o Accumulator: is a SFR closely related to the operation of the ALU. It
is a kind of working desk used for storing all data upon which some
operation should be performed (addition, shift/move etc.).
o It is considered the brain of the microcontrollers.
o It is responsible for executing arithmetic and logic operations.
12
Memory.
© Mohamed F.A.B 2015
o Memory is part of the microcontroller
used for data storage.
o Each memory address corresponds to
one memory location.
o Types of memory within the microcontroller:
o SFR registers.
o RAM (Random Access Memory).
o ROM (Read Only Memory).
o EEPROM (Electrical Erasable ROM).
13
Memory. (cont'd)
© Mohamed F.A.B 2015
o Register:
A register or a memory cell is an electronic circuit
which can memorize the state of one byte.
o Byte.
14
SFR Registers.
© Mohamed F.A.B 2015
o Every microcontroller has a number of registers whose
function is predetermined by the manufacturer.
15
ROM.
© Mohamed F.A.B 2015
o ROM (Read Only Memory) is used to permanently save the
program being executed.
o There are several types of ROM:
o Masked ROM.
Program is loaded into the chip by the manufacturer. In
case of large scale manufacture, the price is very low.
Forget it...
o One Time Programmable ROM.
you can download a program into this memory, but the
process of program downloading is a “one-way ticket”
meaning that it can be done only once.
o UV Erasable Programmable ROM.
It enables the surface of the silicon chip inside to be lit by
an UV lamp, which effectively erases and program from
the ROM.
16
ROM. (cont'd)
© Mohamed F.A.B 2015
o Flash memory:
Since the contents of this memory can be written
and cleared practically an unlimited number of
times, the microcontrollers with Flash ROM are ideal
for learning, experimentation and small-scale
manufacture.
17
RAM.
© Mohamed F.A.B 2015
o It is used for temporary storing data and
intermediate results created and used during the
operation of the microcontroller.
o Once the power supply is off the contents of RAM
(Random Access Memory) is cleared.
18
EEPROM.
© Mohamed F.A.B 2015
o The contents of the EEPROM may be changed
during operation (similar to RAM), but remains
permanently saved even upon the power
supply goes off (similar to ROM).
19
Internal Architecture.
© Mohamed F.A.B 2015
o All upgraded microcontrollers use one of two basic design
models.
o Briefly, they are two different ways of data exchange
between CPU and memory.
o von-Neumann Architecture.
Only one bus for reading instructions
and data at the same time.
o Harvard Architecture.
Two buses, one for Instructions
and another for data.
20
Input/output Ports.
© Mohamed F.A.B 2015
o In order to make the microcontroller useful, it has to be
connected to additional electronics, i.e. peripherals.
Each microcontroller has one or more registers (called
a “port”) connected to the microcontroller pins.
21
Programming MC.
© Mohamed F.A.B 2015
Machine Language.
The microcontroller executes the program loaded in its
Flash memory. This is the so called executable code
comprised of seemingly meaningless sequence of zeros
and ones.
22
Programming MC. cont'd
© Mohamed F.A.B 2015
Assembly Language.
23
Programming MC. cont'd
© Mohamed F.A.B 2015
C Language.
o C Programming is considered a high level language.
24
SW Tools.
© Mohamed F.A.B 2015
o Compiler: It Takes C-Code Then Convert It Into Machine code.
o Assembler : It Takes Assembly Code Then Convert It To Machine Code.
C-Code
File.c
Assembly-Code
File.asm
Machine-Code
File.hex
Dis-assembling
Assembler
CodeVisionAVR contains all previous tools and other useful tools.
25
HW Tools.
© Mohamed F.A.B 2015
o PROGRAMMER or FLASHER : It is a hardware device used to burn or
write code To MC flash memory.
26
Summary.
© Mohamed F.A.B 2015
27
Break.
© Mohamed F.A.B 2015
28
Lesson#2
© Mohamed F.A.B 2015
Lesson (2):
Quick revision in C-Programming language.
29
C-Program Structure.
© Mohamed F.A.B 2015
Information about the project
Main Function
30
Comments In C Programming.
© Mohamed F.A.B 2015
o Comments is some texts which ignored by the compiler.
o It used for documentation.
 There are two types of comments in C programming:
o One-line comment.
EX:
//comment
o Multi-line comment.
EX:
/*
line1
line2
……..
*/
31
Variables.
© Mohamed F.A.B 2015
o Any number changing its value during program
operation is called a variable.
 Declaring Variables:
o Variable name can include any of the alphabetical characters A-
Z (a-z), the digits 0-9 and the underscore character '_'.
o The compiler is case sensitive and differentiates between capital
and small letters.
o Function and variable names usually contain lower case
characters, while constant names contain uppercase characters.
(it is recommended not must).
o Variable names must not start with a digit.
o Some of the names cannot be used as variable names as already
being used by the compiler itself.(key words).
32
Data-Types.
© Mohamed F.A.B 2015
o You should choose the best suitable data-type, since
MC RAM is limited.
o By adding prefix (qualificator) to any data type, the
range of its possible values changes as well as the
number of memory bytes needed.
NOTES
33
Data type Modifiers.
© Mohamed F.A.B 2015
NOTE
o By default any declared variable is signed.
34
Operators.
© Mohamed F.A.B 2015
o Arithmetic Operators:
These are used to perform mathematical calculations like
addition, subtraction, multiplication, division and modulus.
35
Operators. cont’d
© Mohamed F.A.B 2015
o Relational Operators:
These operators are used to compare the value of two variables.
NOTE
The result here will be true or false (0 or 1).
36
Operators. cont’d
© Mohamed F.A.B 2015
o Logical Operators:
These operators are used to perform logical operations on
the given two variables.
NOTE The result here will be true or false (0 or 1).
37
Operators. cont’d
© Mohamed F.A.B 2015
o Bitwise Operators:
These operators are used to perform bit operations on given two
variables.
38
Arrays.
© Mohamed F.A.B 2015
o Array is the simplest and most commonly used structured type.
o A variable of array type is actually an array of objects of the
same type.
o These objects represent elements of an array and are
identified by their position in array (index).
o An array consists of a contiguous region of storage exactly
large enough to hold all of its elements.
EX:
char arr_1[5];
//declare array of 5 character variables.
//here you must define array size.
int arr_2[]={1,2,3,4,5};
//declare array of 5 integer variables and give
initialization values.
//here, you don't need to define array size.
<data type> <array name> [array size] = {e1_val,e2_val,….};
39
If-Statement.
© Mohamed F.A.B 2015
if (condition)
one statement;
0False!0True
Condition
if (condition)
{
Multiple statement;
}if (condition)
{
statement;
statement;
………………………
}
else
{
statement;
statement;
………………………
}
if (condition)
{
statement;
………………………
}
else if (condition)
{
statement;
………………………
}
else
{
statement;
……………………
}
40
Switch-case.
© Mohamed F.A.B 2015
Example:Syntax:
41
For Loop.
© Mohamed F.A.B 2015
for (initial_value ; condition ; update_value)
{
statements;
statements;
…………………………
}
③
① ② ④
True
False
Interactive Question:
What is the output of this program?
for (x=0;5;x++)
{
printf(“M n”);
}
Basic Syntax:
o Step ① only executed one time.
o Use {} for more than one statement.
o for (;;) // infinite loop
NOTE
42
While Loop.
© Mohamed F.A.B 2015
while (condition)
{
statements;
statements;
………………………
}
Basic Syntax:
o Use {} for more than one statement.
o while (1) // infinite loop
NOTE
43
Do ….. While Loop.
© Mohamed F.A.B 2015
do
{
statements;
statements;
………………………
}
while (condition)
Basic Syntax:
o Execute at least one time.
o Use {} for more than one statement.
o Do …… while (1) // infinite loop
NOTE
44
Label Loop.
© Mohamed F.A.B 2015
Loop:
//statement
...
goto loop;
Don't use this method in your code because it
make your code like spaghetti. 
NOTE
45
Control Loop.
© Mohamed F.A.B 2015
break
Continue
o Exit from the nearest loop. Interactive Question:
What is the output of this program?
for (i=0;i<5;i++)
{
if (i == 3) break;
printf(“%d n”,i);
}
o Skip one or more iteration.
Interactive Question:
What is the output of this program?
for (i=0;i<5;i++)
{
if (i == 3) continue;
printf(“%d n”,i);
}
46
Lesson#3
© Mohamed F.A.B 2015
Lesson (3):
Installing Our Working Tools.
47
Codevision AVR.
© Mohamed F.A.B 2015
48
Protuse.
© Mohamed F.A.B 2015
49
Questions:
© Mohamed F.A.B 2015
Thank You All 
50
mo7amed.fawzy33@gmail.com
01006032792
fawzy.fab@gmail.com
© Mohamed F.A.B 2015

More Related Content

What's hot

Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsArkhom Jodtang
 
L13 interrupts-in-atmega328 p
L13 interrupts-in-atmega328 pL13 interrupts-in-atmega328 p
L13 interrupts-in-atmega328 prsamurti
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to ArduinoKarim El-Rayes
 
8051 microcontroller training (2) (sahil gupta 9068557926)
8051 microcontroller training  (2) (sahil gupta   9068557926)8051 microcontroller training  (2) (sahil gupta   9068557926)
8051 microcontroller training (2) (sahil gupta 9068557926)Sahil Gupta
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )Ikhwan_Fakrudin
 
Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingIkhwan_Fakrudin
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpgaHossam Hassan
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)Mashood
 
한컴MDS_TRACE32 제품 소개
한컴MDS_TRACE32 제품 소개한컴MDS_TRACE32 제품 소개
한컴MDS_TRACE32 제품 소개HANCOM MDS
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignmentbabak danyal
 
L11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 pL11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 prsamurti
 

What's hot (15)

Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: Applications
 
L13 interrupts-in-atmega328 p
L13 interrupts-in-atmega328 pL13 interrupts-in-atmega328 p
L13 interrupts-in-atmega328 p
 
Atmega16
Atmega16Atmega16
Atmega16
 
Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
8051 microcontroller training (2) (sahil gupta 9068557926)
8051 microcontroller training  (2) (sahil gupta   9068557926)8051 microcontroller training  (2) (sahil gupta   9068557926)
8051 microcontroller training (2) (sahil gupta 9068557926)
 
Embedded system (Chapter )
Embedded system (Chapter )Embedded system (Chapter )
Embedded system (Chapter )
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 
Embedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programmingEmbedded system (Chapter 3) io_port_programming
Embedded system (Chapter 3) io_port_programming
 
Interfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 MicrocontrollerInterfacing LCD with 8051 Microcontroller
Interfacing LCD with 8051 Microcontroller
 
Calculator design with lcd using fpga
Calculator design with lcd using fpgaCalculator design with lcd using fpga
Calculator design with lcd using fpga
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)
 
한컴MDS_TRACE32 제품 소개
한컴MDS_TRACE32 제품 소개한컴MDS_TRACE32 제품 소개
한컴MDS_TRACE32 제품 소개
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
 
L11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 pL11 assembly-language-programming-of-atmega328 p
L11 assembly-language-programming-of-atmega328 p
 

Viewers also liked

Coursera 7DFDB74V7TJD
Coursera 7DFDB74V7TJDCoursera 7DFDB74V7TJD
Coursera 7DFDB74V7TJDmohamed ahmed
 
Smart real time embedded arduino based data acquisition system
Smart real time embedded arduino based data acquisition systemSmart real time embedded arduino based data acquisition system
Smart real time embedded arduino based data acquisition systemeSAT Journals
 
basic of embedded system
basic of embedded systembasic of embedded system
basic of embedded systemDinesh35833
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMVishal GARG
 
Embedded basics For beginners
Embedded basics For beginnersEmbedded basics For beginners
Embedded basics For beginnersMyEducationHub
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersMohamed Tarek
 
Basics of embedded system design
Basics of embedded system designBasics of embedded system design
Basics of embedded system designK Senthil Kumar
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceKUET
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduinoSantosh Verma
 
Arduino embedded systems and advanced robotics
Arduino embedded systems and advanced roboticsArduino embedded systems and advanced robotics
Arduino embedded systems and advanced roboticsShubham Bhattacharya
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded SystemsMohamed Tarek
 

Viewers also liked (11)

Coursera 7DFDB74V7TJD
Coursera 7DFDB74V7TJDCoursera 7DFDB74V7TJD
Coursera 7DFDB74V7TJD
 
Smart real time embedded arduino based data acquisition system
Smart real time embedded arduino based data acquisition systemSmart real time embedded arduino based data acquisition system
Smart real time embedded arduino based data acquisition system
 
basic of embedded system
basic of embedded systembasic of embedded system
basic of embedded system
 
ARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEMARDUINO EMBEDDED SYSTEM
ARDUINO EMBEDDED SYSTEM
 
Embedded basics For beginners
Embedded basics For beginnersEmbedded basics For beginners
Embedded basics For beginners
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr Microcontrollers
 
Basics of embedded system design
Basics of embedded system designBasics of embedded system design
Basics of embedded system design
 
Serial Communication & Embedded System Interface
Serial Communication & Embedded System InterfaceSerial Communication & Embedded System Interface
Serial Communication & Embedded System Interface
 
Embedded system design using arduino
Embedded system design using arduinoEmbedded system design using arduino
Embedded system design using arduino
 
Arduino embedded systems and advanced robotics
Arduino embedded systems and advanced roboticsArduino embedded systems and advanced robotics
Arduino embedded systems and advanced robotics
 
Introduction to Embedded Systems
Introduction to Embedded SystemsIntroduction to Embedded Systems
Introduction to Embedded Systems
 

Similar to 00 let us get started.2016

Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its typesParth Dodiya
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentationnadim akber
 
1.Introduction to AVR.pdf
1.Introduction to AVR.pdf1.Introduction to AVR.pdf
1.Introduction to AVR.pdfMostafaKhaled78
 
2 8085 microprocessor
2 8085 microprocessor2 8085 microprocessor
2 8085 microprocessoraditidey19
 
Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2satyabrataDash18
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersKamesh Mtec
 
rom-140919103032-phpapp02.pptx
rom-140919103032-phpapp02.pptxrom-140919103032-phpapp02.pptx
rom-140919103032-phpapp02.pptxRAJCHATTERJEE24
 
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONS
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONSUNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONS
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONSDr.YNM
 
ROM(Read Only Memory )
ROM(Read Only Memory )ROM(Read Only Memory )
ROM(Read Only Memory )rohitladdu
 
Rom (read only memory)
Rom (read only memory)Rom (read only memory)
Rom (read only memory)Hemin Patel
 
Memories in digital electronics
Memories in digital electronicsMemories in digital electronics
Memories in digital electronicsSijuGeorge10
 
Read Only Memory
Read Only Memory Read Only Memory
Read Only Memory rohitladdu
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compilerovidlivi91
 

Similar to 00 let us get started.2016 (20)

C programming session10
C programming  session10C programming  session10
C programming session10
 
Embedded C programming session10
Embedded C programming  session10Embedded C programming  session10
Embedded C programming session10
 
Loader and Its types
Loader and Its typesLoader and Its types
Loader and Its types
 
C programming session9 -
C programming  session9 -C programming  session9 -
C programming session9 -
 
Embedded c
Embedded cEmbedded c
Embedded c
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentation
 
1.Introduction to AVR.pdf
1.Introduction to AVR.pdf1.Introduction to AVR.pdf
1.Introduction to AVR.pdf
 
2 8085 microprocessor
2 8085 microprocessor2 8085 microprocessor
2 8085 microprocessor
 
Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2Introduction to assembler_programming_boston_2
Introduction to assembler_programming_boston_2
 
Embedded c program and programming structure for beginners
Embedded c program and programming structure for beginnersEmbedded c program and programming structure for beginners
Embedded c program and programming structure for beginners
 
rom-140919103032-phpapp02.pptx
rom-140919103032-phpapp02.pptxrom-140919103032-phpapp02.pptx
rom-140919103032-phpapp02.pptx
 
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONS
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONSUNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONS
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONS
 
ROM(Read Only Memory )
ROM(Read Only Memory )ROM(Read Only Memory )
ROM(Read Only Memory )
 
Rom (read only memory)
Rom (read only memory)Rom (read only memory)
Rom (read only memory)
 
Memories in digital electronics
Memories in digital electronicsMemories in digital electronics
Memories in digital electronics
 
Unit-2.pptx
Unit-2.pptxUnit-2.pptx
Unit-2.pptx
 
interview questions.docx
interview questions.docxinterview questions.docx
interview questions.docx
 
Embedded C.pptx
Embedded C.pptxEmbedded C.pptx
Embedded C.pptx
 
Read Only Memory
Read Only Memory Read Only Memory
Read Only Memory
 
Compiler design notes phases of compiler
Compiler design notes phases of compilerCompiler design notes phases of compiler
Compiler design notes phases of compiler
 

More from Mohamed Fawzy

07 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).201607 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).2016Mohamed Fawzy
 
أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!Mohamed Fawzy
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.Mohamed Fawzy
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.Mohamed Fawzy
 

More from Mohamed Fawzy (7)

07 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).201607 Analogue to Digital Converter(ADC).2016
07 Analogue to Digital Converter(ADC).2016
 
أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!أزاى تروح فى داهيه !!!
أزاى تروح فى داهيه !!!
 
Ce from a to z
Ce from a to zCe from a to z
Ce from a to z
 
Taqa
TaqaTaqa
Taqa
 
C programming day#2.
C programming day#2.C programming day#2.
C programming day#2.
 
C programming day#3.
C programming day#3.C programming day#3.
C programming day#3.
 
C programming day#1
C programming day#1C programming day#1
C programming day#1
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 

00 let us get started.2016

  • 1. 1 00-Let’s get started By : Mohamed Fawzy Programming AVR Microcontrollers © Mohamed F.A.B 2015
  • 2. Lecture Notes: 2 o Set Your Phone To Vibration Mode. o Ask any time. o During labs, Feel Free To Check Any Materials or Internet. o Slides are self content. o Feel Free To Share This Materials With Your Friends. o Work Hard For Achieving Most Benefits Of This Course. © Mohamed F.A.B 2015
  • 3. 3 Don't Forget !!!! © Mohamed F.A.B 2015 Any Expert Was Once A Beginner 
  • 4. 4 Agenda. Lesson (1): Introduction to micro-controller World. Lesson (2): Quick revision for C programming. Lesson (3): Installing Our Working Tools. © Mohamed F.A.B 2015
  • 5. 5 Lesson#1 Lesson (1): Introduction to micro-controller World. © Mohamed F.A.B 2015
  • 6. 6 Microcontroller. o It is a small computer which can control any thing around the world . o It basically consists of Microprocessor, Memory(RAM, ROM, EEPROM), I/O lines and some other peripherals ……….,etc. DIP Package SMD Package © Mohamed F.A.B 2015
  • 9. 9 Microcontroller Vs. Microprocessor. © Mohamed F.A.B 2015 Microprocessor is a subsystem of Microcontroller system.
  • 10. 10 Internal Components of MC. © Mohamed F.A.B 2015
  • 11. 11 CPU (Central Processing Unit). © Mohamed F.A.B 2015 o Instruction Decoder :is a part of the electronics which recognizes program instructions and runs other circuits on the basis of that. o Arithmetical Logical Unit (ALU): performs all mathematical and logical operations upon data. o Accumulator: is a SFR closely related to the operation of the ALU. It is a kind of working desk used for storing all data upon which some operation should be performed (addition, shift/move etc.). o It is considered the brain of the microcontrollers. o It is responsible for executing arithmetic and logic operations.
  • 12. 12 Memory. © Mohamed F.A.B 2015 o Memory is part of the microcontroller used for data storage. o Each memory address corresponds to one memory location. o Types of memory within the microcontroller: o SFR registers. o RAM (Random Access Memory). o ROM (Read Only Memory). o EEPROM (Electrical Erasable ROM).
  • 13. 13 Memory. (cont'd) © Mohamed F.A.B 2015 o Register: A register or a memory cell is an electronic circuit which can memorize the state of one byte. o Byte.
  • 14. 14 SFR Registers. © Mohamed F.A.B 2015 o Every microcontroller has a number of registers whose function is predetermined by the manufacturer.
  • 15. 15 ROM. © Mohamed F.A.B 2015 o ROM (Read Only Memory) is used to permanently save the program being executed. o There are several types of ROM: o Masked ROM. Program is loaded into the chip by the manufacturer. In case of large scale manufacture, the price is very low. Forget it... o One Time Programmable ROM. you can download a program into this memory, but the process of program downloading is a “one-way ticket” meaning that it can be done only once. o UV Erasable Programmable ROM. It enables the surface of the silicon chip inside to be lit by an UV lamp, which effectively erases and program from the ROM.
  • 16. 16 ROM. (cont'd) © Mohamed F.A.B 2015 o Flash memory: Since the contents of this memory can be written and cleared practically an unlimited number of times, the microcontrollers with Flash ROM are ideal for learning, experimentation and small-scale manufacture.
  • 17. 17 RAM. © Mohamed F.A.B 2015 o It is used for temporary storing data and intermediate results created and used during the operation of the microcontroller. o Once the power supply is off the contents of RAM (Random Access Memory) is cleared.
  • 18. 18 EEPROM. © Mohamed F.A.B 2015 o The contents of the EEPROM may be changed during operation (similar to RAM), but remains permanently saved even upon the power supply goes off (similar to ROM).
  • 19. 19 Internal Architecture. © Mohamed F.A.B 2015 o All upgraded microcontrollers use one of two basic design models. o Briefly, they are two different ways of data exchange between CPU and memory. o von-Neumann Architecture. Only one bus for reading instructions and data at the same time. o Harvard Architecture. Two buses, one for Instructions and another for data.
  • 20. 20 Input/output Ports. © Mohamed F.A.B 2015 o In order to make the microcontroller useful, it has to be connected to additional electronics, i.e. peripherals. Each microcontroller has one or more registers (called a “port”) connected to the microcontroller pins.
  • 21. 21 Programming MC. © Mohamed F.A.B 2015 Machine Language. The microcontroller executes the program loaded in its Flash memory. This is the so called executable code comprised of seemingly meaningless sequence of zeros and ones.
  • 22. 22 Programming MC. cont'd © Mohamed F.A.B 2015 Assembly Language.
  • 23. 23 Programming MC. cont'd © Mohamed F.A.B 2015 C Language. o C Programming is considered a high level language.
  • 24. 24 SW Tools. © Mohamed F.A.B 2015 o Compiler: It Takes C-Code Then Convert It Into Machine code. o Assembler : It Takes Assembly Code Then Convert It To Machine Code. C-Code File.c Assembly-Code File.asm Machine-Code File.hex Dis-assembling Assembler CodeVisionAVR contains all previous tools and other useful tools.
  • 25. 25 HW Tools. © Mohamed F.A.B 2015 o PROGRAMMER or FLASHER : It is a hardware device used to burn or write code To MC flash memory.
  • 28. 28 Lesson#2 © Mohamed F.A.B 2015 Lesson (2): Quick revision in C-Programming language.
  • 29. 29 C-Program Structure. © Mohamed F.A.B 2015 Information about the project Main Function
  • 30. 30 Comments In C Programming. © Mohamed F.A.B 2015 o Comments is some texts which ignored by the compiler. o It used for documentation.  There are two types of comments in C programming: o One-line comment. EX: //comment o Multi-line comment. EX: /* line1 line2 …….. */
  • 31. 31 Variables. © Mohamed F.A.B 2015 o Any number changing its value during program operation is called a variable.  Declaring Variables: o Variable name can include any of the alphabetical characters A- Z (a-z), the digits 0-9 and the underscore character '_'. o The compiler is case sensitive and differentiates between capital and small letters. o Function and variable names usually contain lower case characters, while constant names contain uppercase characters. (it is recommended not must). o Variable names must not start with a digit. o Some of the names cannot be used as variable names as already being used by the compiler itself.(key words).
  • 32. 32 Data-Types. © Mohamed F.A.B 2015 o You should choose the best suitable data-type, since MC RAM is limited. o By adding prefix (qualificator) to any data type, the range of its possible values changes as well as the number of memory bytes needed. NOTES
  • 33. 33 Data type Modifiers. © Mohamed F.A.B 2015 NOTE o By default any declared variable is signed.
  • 34. 34 Operators. © Mohamed F.A.B 2015 o Arithmetic Operators: These are used to perform mathematical calculations like addition, subtraction, multiplication, division and modulus.
  • 35. 35 Operators. cont’d © Mohamed F.A.B 2015 o Relational Operators: These operators are used to compare the value of two variables. NOTE The result here will be true or false (0 or 1).
  • 36. 36 Operators. cont’d © Mohamed F.A.B 2015 o Logical Operators: These operators are used to perform logical operations on the given two variables. NOTE The result here will be true or false (0 or 1).
  • 37. 37 Operators. cont’d © Mohamed F.A.B 2015 o Bitwise Operators: These operators are used to perform bit operations on given two variables.
  • 38. 38 Arrays. © Mohamed F.A.B 2015 o Array is the simplest and most commonly used structured type. o A variable of array type is actually an array of objects of the same type. o These objects represent elements of an array and are identified by their position in array (index). o An array consists of a contiguous region of storage exactly large enough to hold all of its elements. EX: char arr_1[5]; //declare array of 5 character variables. //here you must define array size. int arr_2[]={1,2,3,4,5}; //declare array of 5 integer variables and give initialization values. //here, you don't need to define array size. <data type> <array name> [array size] = {e1_val,e2_val,….};
  • 39. 39 If-Statement. © Mohamed F.A.B 2015 if (condition) one statement; 0False!0True Condition if (condition) { Multiple statement; }if (condition) { statement; statement; ……………………… } else { statement; statement; ……………………… } if (condition) { statement; ……………………… } else if (condition) { statement; ……………………… } else { statement; …………………… }
  • 40. 40 Switch-case. © Mohamed F.A.B 2015 Example:Syntax:
  • 41. 41 For Loop. © Mohamed F.A.B 2015 for (initial_value ; condition ; update_value) { statements; statements; ………………………… } ③ ① ② ④ True False Interactive Question: What is the output of this program? for (x=0;5;x++) { printf(“M n”); } Basic Syntax: o Step ① only executed one time. o Use {} for more than one statement. o for (;;) // infinite loop NOTE
  • 42. 42 While Loop. © Mohamed F.A.B 2015 while (condition) { statements; statements; ……………………… } Basic Syntax: o Use {} for more than one statement. o while (1) // infinite loop NOTE
  • 43. 43 Do ….. While Loop. © Mohamed F.A.B 2015 do { statements; statements; ……………………… } while (condition) Basic Syntax: o Execute at least one time. o Use {} for more than one statement. o Do …… while (1) // infinite loop NOTE
  • 44. 44 Label Loop. © Mohamed F.A.B 2015 Loop: //statement ... goto loop; Don't use this method in your code because it make your code like spaghetti.  NOTE
  • 45. 45 Control Loop. © Mohamed F.A.B 2015 break Continue o Exit from the nearest loop. Interactive Question: What is the output of this program? for (i=0;i<5;i++) { if (i == 3) break; printf(“%d n”,i); } o Skip one or more iteration. Interactive Question: What is the output of this program? for (i=0;i<5;i++) { if (i == 3) continue; printf(“%d n”,i); }
  • 46. 46 Lesson#3 © Mohamed F.A.B 2015 Lesson (3): Installing Our Working Tools.
  • 50. Thank You All  50 mo7amed.fawzy33@gmail.com 01006032792 fawzy.fab@gmail.com © Mohamed F.A.B 2015