SlideShare a Scribd company logo
INTRODUCTION TO MICROCONTROLLERS AND
EMBEDDED SYSTEMS
Prepared by:

Islam Samir
-

Islam Samir Mohamed

-

Electronics and Communications department, Faculty of
Engineering, Cairo University

-

Embedded Software Engineer.
INTRODUCTION
Prequisties:
- Digital logic design, basics of combinational and sequntial
circuits.
- Basics of microprocessors.
 (A brief review will be given in the course)
- C programming language.

INTRODUCTION


-

1.
-

-

Why do we study this course?
As engineers:
Learning how microprocessors work and how to use them is
very essential for every electrical engineer in many ways:
Implementing mathmatical algorithms:
To implement an algorithm for a communication system,
control system, or any real time system we usually write a
program and load it on the target microprocessor.
Then, this microprocessor is used as a part of this system.
INTRODUCTION
2.
-

-

Minimizing the cost and power:
If this system is a part of a battery-powered device, or it’s
required to keep the device’s cost low as much as possible,
we’ve to use a cheap microprocessor.
To do so, the program should be minimized as possible and
the designer should make use of every element of the used
microprocessor/microcontroller.
INTRODUCTION

-

-

-

As Egyptians:
The development of the field of electrical engineering in Egypt
is our responsibility, not anyone else.
To face the challenges facing our country these days, we have
to be at a technical level that allows us to create new products
and compete in the global market.
To do so, we’ve to be equipped with the required knowledge
and experience to innovate and bring new ideas that gives us
the advantage in the market.
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

EMBEDDED SYSTEMS


An embedded system is a special purpose
system that is used to perform one or few
dedicated functions.



Simply, we can call any computer system
embedded inside an electronic device an
embedded system.
EMBEDDED SYSTEMS (CONT.)


Embedded systems are made to
perform few tasks only, after
implementation you can’t use
them for another purposes.

Ex. You can’t watch movies using
the microprocessor of your
microwave oven!!
EMBEDDED SYSTEMS
Examples:
Digital and analog televisions
Set-top boxes (DVDs, VCRs, Cable boxes)
Personal digital assistants (PDAs)
MP3’s and iPod's
Kitchen appliances (refrigerators ,microwave ovens)
Telephones/cell phones
Cameras
Global positioning systems
And many others.
SO.. HOW DO WE IMPLEMENT THEM?


We do so by using microcontrollers (or microprocessor based
systems).



Or simply by using the digital circuits that perform the function we
want.
COMPARISON
Digital circuits

Microprocessor based
systems

Faster
- only propagation delay.

Slower
- Technology dependent.

Inflexible
-Functions they perform
can’t be changed easily.

Flexible
- We need only to update
the software.

Example
- Communication systems
ciphering algorithms.

Example
- Personal computers,
PDA’s, Mobile phones and
PLC’s.
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

WHAT IS A MICROCONTROLLER?


It’s a full computer system on
a chip, even if its resources
are far more limited than of a
desktop personal computer.



Designed for stand alone
operations.
WHAT IS A MICROCONTROLLER? (CONT.)


So.. What’s the difference between a microcontroller and a
microprocessor system?
WHAT IS A MICROCONTROLLER? (CONT.)


A microcontroller has a processor and many peripherals integrated
with it on the same chip, like a flash memory, RAM, I/O ports, serial
communication ports, ADC …Etc.
WHAT IS A MICROCONTROLLER? (CONT.)


A timer module to allow the MCU to perform tasks
for certain time periods.



A serial I/O port to allow data to flow between the
MCU and other devices such as a PC or another
MCU.



An ADC to allow the MCU to accept analog inputs
for processing.
WHAT IS A MICROCONTROLLER? (CONT.)


But a microprocessor can’t do all the functions of a
computer system on its own, and needs another circuits to
support it like:
I/O devices, RAM, ROM, DMA controllers, Timers, ADC,
LCD drivers.. Etc.
COMPARISON
Microcontroller

General purpose microprocessor

Depend mainly on its peripherals
like:
Program memory, I/O ports,
timers, interrupt circuitry,
ADC…Etc.

Depend mainly on other devices like:
I/O devices, memory, DMA controllers
..Etc.

Used for a few dedicated functions
determined by the system
designer.

Used in many applications, according
to the program running on it

Usually used as a part of a larger
system

It’s in the heart of our PC’s.
POPULAR MICROCONTROLLERS
8051 (Intel and others)
 80386 EX (Intel)
 PIC (Microchip)




68HC05 (Motorola)



Z8 (Zilog)
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

DEVELOPING EMBEDDED SYSTEMS
Embedded systems
development

Software
development

Hardware
development
HARDWARE DEVELOPMENT


This includes choosing the right MCU for your application,
so that it can satisfy the required specifications.

The criteria for choosing a microcontroller is:
1- Number of I/O ports.
2- Serial communication modules.
3- Peripherals like (Timer, ADC, PWM ..Etc.)
4- Memory requirements.
5- Processing speed required.
6- Power requirements.


SOFTWARE DEVELOPMENT
• Writing the required algorithm using assembly
or a high level language.
• Using a compiler or assembler and a linker.

• Debugging your code.
SOFTWARE DEVELOPMENT

Compiler

Assembler
SOFTWARE DEVELOPMENT


Using assembly involves learning the used microcontroller's
specific instruction set but results in the most compact and fastest
code.



Using C programming language makes your code portable,
which means that you can use it for another target microcontroller
without learning its instruction set, this eases the process of
software development (short time to market) with acceptable quality.
C VS ASSEMBLY

Assembly programs are optimized more than C programs, but
to develop more complicated programs, using C is more
practical and also efficient.
LINKER


The linker’s function is to link code modules saved in
different files together into a single final program .



At the same time it takes care of the chip's memory
allocation by assigning each instruction to a
microcontroller memory addresses in such a way that
different modules do not overlap.
DEBUGGER
Common debugging features include:
1.
The capability to examine and modify the
microcontroller's on-chip registers, data- and
program-memory.



2.

Pausing or stopping program executing at defined
program locations by setting breakpoints.

3.

Single-stepping (execute one instruction at a time)
through the code; and looking at a history of executed
code (trace).
SOFTWARE DEVELOPMENT


An Integrated Development Environment (IDE) puts
all of the previously discussed software components
under one common unified user interface.
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

ARCHITECTURE (MEMORY ACCESSING)
Von Neumann
One memory for data and program,
with one bus for both.
CPU provides address to get data
or instructions.
Data and instructions must have
the same width.

Harvard
-Separate program and data memories and
separate busses, can be accessed
simultaneously.

separated buses allow one instruction to
execute while the next instruction is fetched.
Data and instructions mustn’t have the same
width.
ARCHITECTURE (NUMBER OF INSTRUCTIONS)
CISC Processors:
-A large no. of instructions requiring
different no. of clock cycles.
Support many addressing modes.
More complex operations are
implemented in hardware and more
elaborate way of accessing data.

RISC Processors:
-Less no. of instructions.
-Instructions are of fixed length. This
facilitates ins. pipelining as when the CPU
fetches a new ins. It will depend only on the
address not on the pervious ins.
-Few addressing modes.
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

PIC MICROCONTROLLERS


One of the leading architectures for low
end applications (app.'s that require only
4-bit, 8-bit or 16-bit processors).



They are RISC, Harvard architecture
processors.



Easier implementation to pipelining
without having a complex hardware, less
silicon area and less power consumption.
PIC MICROCONTROLLERS


PICmicro devices architectural features:

1 – Harvard, RISC architecture.
2 - Single Word Instructions.
Each instruction takes one word of memory (14-bits).

3 - Single Cycle Instructions.
Each instruction is fetched in one instruction cycle, decoded and executed in the
next instruction cycle.
4 - Instruction Pipelining

An instruction is fetched and another instruction is executed at the same time every
single TCY.
PIC MICROCONTROLLERS


The one we’ll use is: PIC 16f877A
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

OSCILLATOR


1.
2.

You’ve to choose the suitable oscillator mode you’ll use in your
application, according to:
The required processing speed.
The required timing precision.
OSCILLATOR
1.
-

2.
-

-

External RC Oscillator:
Depend on the value of Rext, Cext, the supply voltage and
the temperature.
Less cost compared to using a crystal.
Internal 4 MHz RC Oscillator:
provides a fixed 4 MHz (nominal) system clock at VDD = 5V
and 25°C.
The value in the OSCCAL register is used to tune the
frequency of the internal RC oscillator.
OSCILLATOR
3-Crystal oscillator:
-A crystal or ceramic resonator is connected to the OSC1 and OSC2
pins to establish oscillation.
- Used for high precession timing requirements.
-The capacitors are chosen according to the frequency and the
preferred values in the datasheet of the used device.
INSTRUCTION CYCLE




We call the time of fetching, decoding and executing an
instruction, the instruction cycle.
For PICmicro devices:

Instruction cycle = 4 oscillator clock cycles
INSTRUCTION CYCLE


Actually, each instruction is fetched in one instruction cycle, and
then decoded and executed in another ins. cycle.



Due to using pipelining, while the current instruction is fetched, the
pervious instruction is executed. So, you can say that each
instruction is fetched, decoded and executed in one instruction
cycle (4 clock cycles).
INSTRUCTION CYCLE


The instruction fetch begins with the program counter
incrementing in Q1.



In the execution cycle, the fetched instruction is latched
into the “Instruction Register (IR)” in cycle Q1. This
instruction is then decoded and executed during the Q2, Q3
and Q4 cycles. Data memory is read during Q2 (operand
read) and written during Q4 (destination write).
INSTRUCTION CYCLE
Ex. If you use a 4MHZ oscillator, the MCU will execute 1Million
instruction per second (1 MIPS)
Clock frequency (4MHZ) = Instruction execution (1MHZ)
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

MEMORY ORGANIZATION



There are two memory blocks:
Program memory.
Data memory.
Each one has its own bus. so that access to each block
can occur during the same oscillator cycle.
MEMORY ORGANIZATION
Program memory:
- 8 K×14 program memory space, capable of carrying 8K
instructions.
- Reset vector  0000h
 the place in memory the CPU branches to when a reset
occurs.
- Interrupt vector  0004h
-  the place in memory the CPU branches to when there is an
interrupt signal.
- 13-bit program counter.
- Program memory is partitioned to 4 banks, chosen by writing
the PCLATH<4:3> bits before executing any CALL or GOTO
instruction.
[11bit from op-code + 2 paging bits]

MEMORY ORGANIZATION
Stack:
- 8 level stack allow up to 8 program calls / interrupts to
occur.
- The return address (13-bit) will be PUSHed into the
stack so that the CPU knows from to continue.
- When a return instruction is executed, the whole 13bits
of PC are POPed from the stack.
- The stack pointer is not readable or writable.
- There are no PUSH or POP instructions.
MEMORY ORGANIZATION

-

-

-

-

Data memory:
Contains of general purpose registers (GPRs), and
special function registers (SFRs).
SFRs control the functions of the core and the
peripherals.
GPRs are not initialized by a power up on reset, and
unchanged on all other resets.
Data memory is partitioned to 4 banks, each bank is 128
byte.
MEMORY ORGANIZATION
Direct addressing:
- The bank selection bits are used
[STATUS <6:5>].

Indirect addressing:
- Data memory address is not fixed.
- The address is first defined in the SFR
register. then any access to the INDF register
will access the register pointed to by the SFR
register.
AGENDA
What are embedded systems? How do we
implement them?
 What is a microcontroller?
 Developing embedded applications using MCU’s.
 Basics of architecture.
 PIC microcontrollers.
 Basics of PICmicro devices architecture.
 Memory organization and addressing modes.
 C programming language.

C PROGRAMMING LANGUAGE
Features of C:











Extensive use of function calls
Low level (Bitwise) programming readily available
Pointer implementation - extensive use of pointers for memory
and arrays.
Structures and functions.
Can handle low-level activities.
Produces efficient programs.
Fast.
It can be compiled on a variety of computers.
C PROGRAMMING LANGUAGE
General form for any C program:
DATA TYPES
Type Bit Width Range:
Char

8

0 to 255

unsigned Char

8

0 to 255

Signed Char

8

-128 to 127

short

16

0 or 65536

long

32

0 to 65536

float

32

3.4E-38 to 3.4E+38

-

For each variable we should Know: Sign, Size and the variable’s name.
OPERATORS
+ addition
- subtraction

* multiplication
/ division
% modulus


a*=b is the same as a=a*b



a/=b





a+=b





a-=b





a%=b



a=a%b



a<<=b



a=a<<b



a>>=b



a=a>>b



a&=b





a|=b





a^=b



a=a/b
a=a+b
a=a-b

a=a&b
a=a|b
a=a^b
OPERATORS
Relational operators:
>,<,<=,>=,==,!=

Logical operators:
&&,||,!
Bitwise operators:
&, |, ^ (XOR), <<,>>,~

Precedence:
1.

Casting

2.

Parentheses

3.

Negative

4.

Multiplication and division

5.

Addition and subtraction
CONDITIONAL STATEMENTS
If statement:
if (expression)
{
statement(s);
}
If-else statement:
if (expression1)
{
statement(s)
}
else if(expression2)
{
statement(s)
}
else
{
statement(s)
}
SWITCH STATEMENT


switch (variable)

{

case constant1:
statement(s);
break;
case constant2:

statement(s);
break;
default:
statement(s);
}
FOR LOOP


for( initialization ; conditional_test ; increment )

Ex.


void main(void)

{
int i;
for(i=0; i<10; i++)

printf(“%d “,i);
printf(“done”);
}
WHILE & DO-WHILE LOOP
While:
while (expression)

{
statement;
}
do-while Loop


do

{
statements
}
while(expression)
ARRAYS
type array_name[size] = {value list};

Ex.


int i[5] = {1,2,3,4,5};

Multidimensional arrays:


int num[3][3]={ 1,2,3,
4,5,6,
7,8,9};
FUNCTIONS


main() is the first function called when the program is executed. The other
functions, function1() and function2(), can be called by any function in the
program.

Example.
main()
{
int x=0;
X=Function1(5,6);
}
int function1(int a,int b )
{
Return (a+b);
}
MIX C AND ASSEMBLY



We can mix c and assembly by using the command
#asm
statements



#End asm

More Related Content

What's hot

Arduino Uno Pin Description
Arduino Uno Pin DescriptionArduino Uno Pin Description
Arduino Uno Pin Description
Niket Chandrawanshi
 
Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
Prof. Erwin Globio
 
Arduino uno
Arduino unoArduino uno
Embedded os
Embedded osEmbedded os
Embedded os
chian417
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)
Mandeesh Singh
 
Introduction to embedded system design
Introduction to embedded system designIntroduction to embedded system design
Introduction to embedded system design
Mukesh Bansal
 
Embedded system
Embedded systemEmbedded system
Embedded system
Vinod Srivastava
 
ARDUINO AND ITS PIN CONFIGURATION
 ARDUINO AND ITS PIN  CONFIGURATION ARDUINO AND ITS PIN  CONFIGURATION
ARDUINO AND ITS PIN CONFIGURATION
soma saikiran
 
Arduino uno
Arduino unoArduino uno
Arduino uno
creatjet3d labs
 
Arduino uno lcd display 16x2
Arduino uno lcd display 16x2Arduino uno lcd display 16x2
Arduino uno lcd display 16x2
Robomart India
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
Jawaher Abdulwahab Fadhil
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller
Raghav Shetty
 
Arduino
ArduinoArduino
Arduino
vipin7vj
 
Embedded system
Embedded systemEmbedded system
Embedded system
Pankaj Upadhyay
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
Nikhil Sharma
 
programmable logic controller presentation
programmable logic controller presentationprogrammable logic controller presentation
programmable logic controller presentation
Ashutosh Verma
 
Question Bank Programmable Logic Controller
Question Bank Programmable Logic ControllerQuestion Bank Programmable Logic Controller
Question Bank Programmable Logic Controller
Nilesh Bhaskarrao Bahadure
 
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Shrishail Bhat
 
CS4109 Computer System Architecture
CS4109 Computer System ArchitectureCS4109 Computer System Architecture
CS4109 Computer System Architecture
ktosri
 
Ardui no
Ardui no Ardui no
Ardui no
Amol Sakhalkar
 

What's hot (20)

Arduino Uno Pin Description
Arduino Uno Pin DescriptionArduino Uno Pin Description
Arduino Uno Pin Description
 
Embedded System Presentation
Embedded System PresentationEmbedded System Presentation
Embedded System Presentation
 
Arduino uno
Arduino unoArduino uno
Arduino uno
 
Embedded os
Embedded osEmbedded os
Embedded os
 
Raspberry Pi (Introduction)
Raspberry Pi (Introduction)Raspberry Pi (Introduction)
Raspberry Pi (Introduction)
 
Introduction to embedded system design
Introduction to embedded system designIntroduction to embedded system design
Introduction to embedded system design
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
ARDUINO AND ITS PIN CONFIGURATION
 ARDUINO AND ITS PIN  CONFIGURATION ARDUINO AND ITS PIN  CONFIGURATION
ARDUINO AND ITS PIN CONFIGURATION
 
Arduino uno
Arduino unoArduino uno
Arduino uno
 
Arduino uno lcd display 16x2
Arduino uno lcd display 16x2Arduino uno lcd display 16x2
Arduino uno lcd display 16x2
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller
 
Arduino
ArduinoArduino
Arduino
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
programmable logic controller presentation
programmable logic controller presentationprogrammable logic controller presentation
programmable logic controller presentation
 
Question Bank Programmable Logic Controller
Question Bank Programmable Logic ControllerQuestion Bank Programmable Logic Controller
Question Bank Programmable Logic Controller
 
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
Embedded Systems (18EC62) – Embedded System Design Concepts (Module 4)
 
CS4109 Computer System Architecture
CS4109 Computer System ArchitectureCS4109 Computer System Architecture
CS4109 Computer System Architecture
 
Ardui no
Ardui no Ardui no
Ardui no
 

Viewers also liked

Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontroller
Amandeep Alag
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
Islam Samir
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
Muhammad Abdullah
 
Timers
TimersTimers
Timers
Islam Samir
 
Interrupts
InterruptsInterrupts
Interrupts
Islam Samir
 
I/O Ports
I/O Ports I/O Ports
I/O Ports
Islam Samir
 
USART
USARTUSART

Viewers also liked (7)

Embedded systems, 8051 microcontroller
Embedded systems, 8051 microcontrollerEmbedded systems, 8051 microcontroller
Embedded systems, 8051 microcontroller
 
Interfacing to the analog world
Interfacing to the analog worldInterfacing to the analog world
Interfacing to the analog world
 
Solution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidiSolution manual 8051 microcontroller by mazidi
Solution manual 8051 microcontroller by mazidi
 
Timers
TimersTimers
Timers
 
Interrupts
InterruptsInterrupts
Interrupts
 
I/O Ports
I/O Ports I/O Ports
I/O Ports
 
USART
USARTUSART
USART
 

Similar to Introduction to Embedded Systems and Microcontrollers

Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
sidhantkulkarni1
 
Embedded system
Embedded systemEmbedded system
Embedded system
Anmol Bagga
 
Embeddedsystem
EmbeddedsystemEmbeddedsystem
Embeddedsystem
anshul parmar
 
Project Report on Embedded Systems
Project Report on Embedded Systems Project Report on Embedded Systems
Project Report on Embedded Systems
Suhani Singh
 
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdfIntroduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
aienterpresses
 
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdfIntroduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
aienterpresses
 
Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontroller
Vandna Sambyal
 
8051 microcontroller and embedded system
8051 microcontroller and embedded system8051 microcontroller and embedded system
8051 microcontroller and embedded system
sb108ec
 
lec 1Embedded System Design ppt.pptx
lec 1Embedded System Design ppt.pptxlec 1Embedded System Design ppt.pptx
lec 1Embedded System Design ppt.pptx
dhanashribiradar2
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
Sagar Kumar
 
microprocessor-and-microcontroller
microprocessor-and-microcontrollermicroprocessor-and-microcontroller
microprocessor-and-microcontroller
jhcid
 
An introduction to digital signal processors 1
An introduction to digital signal processors 1An introduction to digital signal processors 1
An introduction to digital signal processors 1
Hossam Hassan
 
Microprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptMicroprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.ppt
TALHARIAZ46
 
Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6
Ananda Gopathoti
 
K.Bhagavan gupta.pdf according to the labu
K.Bhagavan gupta.pdf according to the labuK.Bhagavan gupta.pdf according to the labu
K.Bhagavan gupta.pdf according to the labu
ShanmukhVegi
 
BEE 049- design of embedded system.pdf
BEE 049- design of embedded system.pdfBEE 049- design of embedded system.pdf
BEE 049- design of embedded system.pdf
abdisahirko
 
An entire concept of embedded systems entire ppt
An entire concept of embedded systems entire pptAn entire concept of embedded systems entire ppt
An entire concept of embedded systems entire ppt
Prabhakar Captain
 
An Entire Concept of Embedded systems
An Entire Concept of Embedded systems An Entire Concept of Embedded systems
An Entire Concept of Embedded systems
Prabhakar Captain
 
Embedded
EmbeddedEmbedded
Embedded
bala saga
 
Density based traffic light controlling (2)
Density based traffic light controlling (2)Density based traffic light controlling (2)
Density based traffic light controlling (2)
hardik1240
 

Similar to Introduction to Embedded Systems and Microcontrollers (20)

Unit-1.pptx
Unit-1.pptxUnit-1.pptx
Unit-1.pptx
 
Embedded system
Embedded systemEmbedded system
Embedded system
 
Embeddedsystem
EmbeddedsystemEmbeddedsystem
Embeddedsystem
 
Project Report on Embedded Systems
Project Report on Embedded Systems Project Report on Embedded Systems
Project Report on Embedded Systems
 
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdfIntroduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
Introduction to embedded systems using the msp430 6. 1 Enumerate the.pdf
 
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdfIntroduction to embedded systems using the msp430 6.1 Enumerate the .pdf
Introduction to embedded systems using the msp430 6.1 Enumerate the .pdf
 
Project report on embedded system using 8051 microcontroller
Project  report on embedded system using 8051 microcontrollerProject  report on embedded system using 8051 microcontroller
Project report on embedded system using 8051 microcontroller
 
8051 microcontroller and embedded system
8051 microcontroller and embedded system8051 microcontroller and embedded system
8051 microcontroller and embedded system
 
lec 1Embedded System Design ppt.pptx
lec 1Embedded System Design ppt.pptxlec 1Embedded System Design ppt.pptx
lec 1Embedded System Design ppt.pptx
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
microprocessor-and-microcontroller
microprocessor-and-microcontrollermicroprocessor-and-microcontroller
microprocessor-and-microcontroller
 
An introduction to digital signal processors 1
An introduction to digital signal processors 1An introduction to digital signal processors 1
An introduction to digital signal processors 1
 
Microprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.pptMicroprocessor and Microcontroller Based Systems.ppt
Microprocessor and Microcontroller Based Systems.ppt
 
Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6Introduction to DSP Processors-UNIT-6
Introduction to DSP Processors-UNIT-6
 
K.Bhagavan gupta.pdf according to the labu
K.Bhagavan gupta.pdf according to the labuK.Bhagavan gupta.pdf according to the labu
K.Bhagavan gupta.pdf according to the labu
 
BEE 049- design of embedded system.pdf
BEE 049- design of embedded system.pdfBEE 049- design of embedded system.pdf
BEE 049- design of embedded system.pdf
 
An entire concept of embedded systems entire ppt
An entire concept of embedded systems entire pptAn entire concept of embedded systems entire ppt
An entire concept of embedded systems entire ppt
 
An Entire Concept of Embedded systems
An Entire Concept of Embedded systems An Entire Concept of Embedded systems
An Entire Concept of Embedded systems
 
Embedded
EmbeddedEmbedded
Embedded
 
Density based traffic light controlling (2)
Density based traffic light controlling (2)Density based traffic light controlling (2)
Density based traffic light controlling (2)
 

Recently uploaded

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 

Recently uploaded (20)

Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 

Introduction to Embedded Systems and Microcontrollers

  • 1. INTRODUCTION TO MICROCONTROLLERS AND EMBEDDED SYSTEMS Prepared by: Islam Samir
  • 2. - Islam Samir Mohamed - Electronics and Communications department, Faculty of Engineering, Cairo University - Embedded Software Engineer.
  • 3. INTRODUCTION Prequisties: - Digital logic design, basics of combinational and sequntial circuits. - Basics of microprocessors.  (A brief review will be given in the course) - C programming language. 
  • 4. INTRODUCTION   - 1. - - Why do we study this course? As engineers: Learning how microprocessors work and how to use them is very essential for every electrical engineer in many ways: Implementing mathmatical algorithms: To implement an algorithm for a communication system, control system, or any real time system we usually write a program and load it on the target microprocessor. Then, this microprocessor is used as a part of this system.
  • 5.
  • 6. INTRODUCTION 2. - - Minimizing the cost and power: If this system is a part of a battery-powered device, or it’s required to keep the device’s cost low as much as possible, we’ve to use a cheap microprocessor. To do so, the program should be minimized as possible and the designer should make use of every element of the used microprocessor/microcontroller.
  • 7. INTRODUCTION  - - - As Egyptians: The development of the field of electrical engineering in Egypt is our responsibility, not anyone else. To face the challenges facing our country these days, we have to be at a technical level that allows us to create new products and compete in the global market. To do so, we’ve to be equipped with the required knowledge and experience to innovate and bring new ideas that gives us the advantage in the market.
  • 8. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 9. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 10. EMBEDDED SYSTEMS  An embedded system is a special purpose system that is used to perform one or few dedicated functions.  Simply, we can call any computer system embedded inside an electronic device an embedded system.
  • 11. EMBEDDED SYSTEMS (CONT.)  Embedded systems are made to perform few tasks only, after implementation you can’t use them for another purposes. Ex. You can’t watch movies using the microprocessor of your microwave oven!!
  • 12. EMBEDDED SYSTEMS Examples: Digital and analog televisions Set-top boxes (DVDs, VCRs, Cable boxes) Personal digital assistants (PDAs) MP3’s and iPod's Kitchen appliances (refrigerators ,microwave ovens) Telephones/cell phones Cameras Global positioning systems And many others.
  • 13. SO.. HOW DO WE IMPLEMENT THEM?  We do so by using microcontrollers (or microprocessor based systems).  Or simply by using the digital circuits that perform the function we want.
  • 14. COMPARISON Digital circuits Microprocessor based systems Faster - only propagation delay. Slower - Technology dependent. Inflexible -Functions they perform can’t be changed easily. Flexible - We need only to update the software. Example - Communication systems ciphering algorithms. Example - Personal computers, PDA’s, Mobile phones and PLC’s.
  • 15. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 16. WHAT IS A MICROCONTROLLER?  It’s a full computer system on a chip, even if its resources are far more limited than of a desktop personal computer.  Designed for stand alone operations.
  • 17. WHAT IS A MICROCONTROLLER? (CONT.)  So.. What’s the difference between a microcontroller and a microprocessor system?
  • 18. WHAT IS A MICROCONTROLLER? (CONT.)  A microcontroller has a processor and many peripherals integrated with it on the same chip, like a flash memory, RAM, I/O ports, serial communication ports, ADC …Etc.
  • 19. WHAT IS A MICROCONTROLLER? (CONT.)  A timer module to allow the MCU to perform tasks for certain time periods.  A serial I/O port to allow data to flow between the MCU and other devices such as a PC or another MCU.  An ADC to allow the MCU to accept analog inputs for processing.
  • 20. WHAT IS A MICROCONTROLLER? (CONT.)  But a microprocessor can’t do all the functions of a computer system on its own, and needs another circuits to support it like: I/O devices, RAM, ROM, DMA controllers, Timers, ADC, LCD drivers.. Etc.
  • 21. COMPARISON Microcontroller General purpose microprocessor Depend mainly on its peripherals like: Program memory, I/O ports, timers, interrupt circuitry, ADC…Etc. Depend mainly on other devices like: I/O devices, memory, DMA controllers ..Etc. Used for a few dedicated functions determined by the system designer. Used in many applications, according to the program running on it Usually used as a part of a larger system It’s in the heart of our PC’s.
  • 22. POPULAR MICROCONTROLLERS 8051 (Intel and others)  80386 EX (Intel)  PIC (Microchip)   68HC05 (Motorola)  Z8 (Zilog)
  • 23. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 24. DEVELOPING EMBEDDED SYSTEMS Embedded systems development Software development Hardware development
  • 25. HARDWARE DEVELOPMENT  This includes choosing the right MCU for your application, so that it can satisfy the required specifications. The criteria for choosing a microcontroller is: 1- Number of I/O ports. 2- Serial communication modules. 3- Peripherals like (Timer, ADC, PWM ..Etc.) 4- Memory requirements. 5- Processing speed required. 6- Power requirements. 
  • 26. SOFTWARE DEVELOPMENT • Writing the required algorithm using assembly or a high level language. • Using a compiler or assembler and a linker. • Debugging your code.
  • 28. SOFTWARE DEVELOPMENT  Using assembly involves learning the used microcontroller's specific instruction set but results in the most compact and fastest code.  Using C programming language makes your code portable, which means that you can use it for another target microcontroller without learning its instruction set, this eases the process of software development (short time to market) with acceptable quality.
  • 29. C VS ASSEMBLY Assembly programs are optimized more than C programs, but to develop more complicated programs, using C is more practical and also efficient.
  • 30. LINKER  The linker’s function is to link code modules saved in different files together into a single final program .  At the same time it takes care of the chip's memory allocation by assigning each instruction to a microcontroller memory addresses in such a way that different modules do not overlap.
  • 31. DEBUGGER Common debugging features include: 1. The capability to examine and modify the microcontroller's on-chip registers, data- and program-memory.  2. Pausing or stopping program executing at defined program locations by setting breakpoints. 3. Single-stepping (execute one instruction at a time) through the code; and looking at a history of executed code (trace).
  • 32. SOFTWARE DEVELOPMENT  An Integrated Development Environment (IDE) puts all of the previously discussed software components under one common unified user interface.
  • 33. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 34. ARCHITECTURE (MEMORY ACCESSING) Von Neumann One memory for data and program, with one bus for both. CPU provides address to get data or instructions. Data and instructions must have the same width. Harvard -Separate program and data memories and separate busses, can be accessed simultaneously. separated buses allow one instruction to execute while the next instruction is fetched. Data and instructions mustn’t have the same width.
  • 35. ARCHITECTURE (NUMBER OF INSTRUCTIONS) CISC Processors: -A large no. of instructions requiring different no. of clock cycles. Support many addressing modes. More complex operations are implemented in hardware and more elaborate way of accessing data. RISC Processors: -Less no. of instructions. -Instructions are of fixed length. This facilitates ins. pipelining as when the CPU fetches a new ins. It will depend only on the address not on the pervious ins. -Few addressing modes.
  • 36. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 37. PIC MICROCONTROLLERS  One of the leading architectures for low end applications (app.'s that require only 4-bit, 8-bit or 16-bit processors).  They are RISC, Harvard architecture processors.  Easier implementation to pipelining without having a complex hardware, less silicon area and less power consumption.
  • 38. PIC MICROCONTROLLERS  PICmicro devices architectural features: 1 – Harvard, RISC architecture. 2 - Single Word Instructions. Each instruction takes one word of memory (14-bits). 3 - Single Cycle Instructions. Each instruction is fetched in one instruction cycle, decoded and executed in the next instruction cycle. 4 - Instruction Pipelining An instruction is fetched and another instruction is executed at the same time every single TCY.
  • 39. PIC MICROCONTROLLERS  The one we’ll use is: PIC 16f877A
  • 40. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 41. OSCILLATOR  1. 2. You’ve to choose the suitable oscillator mode you’ll use in your application, according to: The required processing speed. The required timing precision.
  • 42. OSCILLATOR 1. - 2. - - External RC Oscillator: Depend on the value of Rext, Cext, the supply voltage and the temperature. Less cost compared to using a crystal. Internal 4 MHz RC Oscillator: provides a fixed 4 MHz (nominal) system clock at VDD = 5V and 25°C. The value in the OSCCAL register is used to tune the frequency of the internal RC oscillator.
  • 43. OSCILLATOR 3-Crystal oscillator: -A crystal or ceramic resonator is connected to the OSC1 and OSC2 pins to establish oscillation. - Used for high precession timing requirements. -The capacitors are chosen according to the frequency and the preferred values in the datasheet of the used device.
  • 44. INSTRUCTION CYCLE   We call the time of fetching, decoding and executing an instruction, the instruction cycle. For PICmicro devices: Instruction cycle = 4 oscillator clock cycles
  • 45. INSTRUCTION CYCLE  Actually, each instruction is fetched in one instruction cycle, and then decoded and executed in another ins. cycle.  Due to using pipelining, while the current instruction is fetched, the pervious instruction is executed. So, you can say that each instruction is fetched, decoded and executed in one instruction cycle (4 clock cycles).
  • 46. INSTRUCTION CYCLE  The instruction fetch begins with the program counter incrementing in Q1.  In the execution cycle, the fetched instruction is latched into the “Instruction Register (IR)” in cycle Q1. This instruction is then decoded and executed during the Q2, Q3 and Q4 cycles. Data memory is read during Q2 (operand read) and written during Q4 (destination write).
  • 47. INSTRUCTION CYCLE Ex. If you use a 4MHZ oscillator, the MCU will execute 1Million instruction per second (1 MIPS) Clock frequency (4MHZ) = Instruction execution (1MHZ)
  • 48. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 49. MEMORY ORGANIZATION   There are two memory blocks: Program memory. Data memory. Each one has its own bus. so that access to each block can occur during the same oscillator cycle.
  • 50. MEMORY ORGANIZATION Program memory: - 8 K×14 program memory space, capable of carrying 8K instructions. - Reset vector  0000h  the place in memory the CPU branches to when a reset occurs. - Interrupt vector  0004h -  the place in memory the CPU branches to when there is an interrupt signal. - 13-bit program counter. - Program memory is partitioned to 4 banks, chosen by writing the PCLATH<4:3> bits before executing any CALL or GOTO instruction. [11bit from op-code + 2 paging bits] 
  • 51.
  • 52. MEMORY ORGANIZATION Stack: - 8 level stack allow up to 8 program calls / interrupts to occur. - The return address (13-bit) will be PUSHed into the stack so that the CPU knows from to continue. - When a return instruction is executed, the whole 13bits of PC are POPed from the stack. - The stack pointer is not readable or writable. - There are no PUSH or POP instructions.
  • 53. MEMORY ORGANIZATION  - - - - Data memory: Contains of general purpose registers (GPRs), and special function registers (SFRs). SFRs control the functions of the core and the peripherals. GPRs are not initialized by a power up on reset, and unchanged on all other resets. Data memory is partitioned to 4 banks, each bank is 128 byte.
  • 54. MEMORY ORGANIZATION Direct addressing: - The bank selection bits are used [STATUS <6:5>]. Indirect addressing: - Data memory address is not fixed. - The address is first defined in the SFR register. then any access to the INDF register will access the register pointed to by the SFR register.
  • 55. AGENDA What are embedded systems? How do we implement them?  What is a microcontroller?  Developing embedded applications using MCU’s.  Basics of architecture.  PIC microcontrollers.  Basics of PICmicro devices architecture.  Memory organization and addressing modes.  C programming language. 
  • 56. C PROGRAMMING LANGUAGE Features of C:         Extensive use of function calls Low level (Bitwise) programming readily available Pointer implementation - extensive use of pointers for memory and arrays. Structures and functions. Can handle low-level activities. Produces efficient programs. Fast. It can be compiled on a variety of computers.
  • 57. C PROGRAMMING LANGUAGE General form for any C program:
  • 58. DATA TYPES Type Bit Width Range: Char 8 0 to 255 unsigned Char 8 0 to 255 Signed Char 8 -128 to 127 short 16 0 or 65536 long 32 0 to 65536 float 32 3.4E-38 to 3.4E+38 - For each variable we should Know: Sign, Size and the variable’s name.
  • 59. OPERATORS + addition - subtraction * multiplication / division % modulus  a*=b is the same as a=a*b  a/=b   a+=b   a-=b   a%=b  a=a%b  a<<=b  a=a<<b  a>>=b  a=a>>b  a&=b   a|=b   a^=b  a=a/b a=a+b a=a-b a=a&b a=a|b a=a^b
  • 60. OPERATORS Relational operators: >,<,<=,>=,==,!= Logical operators: &&,||,! Bitwise operators: &, |, ^ (XOR), <<,>>,~ Precedence: 1. Casting 2. Parentheses 3. Negative 4. Multiplication and division 5. Addition and subtraction
  • 61. CONDITIONAL STATEMENTS If statement: if (expression) { statement(s); } If-else statement: if (expression1) { statement(s) } else if(expression2) { statement(s) } else { statement(s) }
  • 62. SWITCH STATEMENT  switch (variable) { case constant1: statement(s); break; case constant2: statement(s); break; default: statement(s); }
  • 63. FOR LOOP  for( initialization ; conditional_test ; increment ) Ex.  void main(void) { int i; for(i=0; i<10; i++) printf(“%d “,i); printf(“done”); }
  • 64. WHILE & DO-WHILE LOOP While: while (expression) { statement; } do-while Loop  do { statements } while(expression)
  • 65. ARRAYS type array_name[size] = {value list}; Ex.  int i[5] = {1,2,3,4,5}; Multidimensional arrays:  int num[3][3]={ 1,2,3, 4,5,6, 7,8,9};
  • 66. FUNCTIONS  main() is the first function called when the program is executed. The other functions, function1() and function2(), can be called by any function in the program. Example. main() { int x=0; X=Function1(5,6); } int function1(int a,int b ) { Return (a+b); }
  • 67. MIX C AND ASSEMBLY   We can mix c and assembly by using the command #asm statements  #End asm