0% found this document useful (0 votes)
66 views35 pages

8051 Lec2-Fd

Uploaded by

omar.66ashraf6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views35 pages

8051 Lec2-Fd

Uploaded by

omar.66ashraf6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

EMBEDDED SYSTEMS

LECTURE 2

1
Microcontroller Burning procedures

Software
Burner Assembly
4 Assembler
code
Filename.asm
5
Filename.HEX 3 1 2

Filename.C
Firmware

C or MikroC
Compiler
To code Filename.h
HW
Simulator “as Proteus”
USB

6 Training-KIT
AT89c51 To Embedded system

2
Is assembly and assembler the same?

• The Assembler is a Software that converts an


assembly language code to machine code.
• It takes basic Computer commands and
converts them into Binary Code that
Computer's Processor can use to perform its
Basic Operations.
• These instructions are assembler language or
assembly language

3
• Emulator: another way to run the program is
using emulator.
• It is a mixture of hardware and software.
• •It is used to teat and debug external systems.

4
5
• Debugger: if your program does not require
external hardware or requires only hardware
accessible directly from your microcomputer
then you can use a debugger to run and debug
your program.
•It allows you to load your object code program
and troubleshoot it.

6
• LINKER: it is a program used to join several object
files into one object file.
•The linker produces link file which contains the
binary codes for all combined modules.
•The linker also produces a link map file which
contains the address information about the linked
files.
•The produced link files have the extension .EXE
and .MAP
7
difference between assembly and instruction set?

The main difference is that


• assembly language is meant to be read,
written, and otherwise manipulated by
humans, while machine code is executed
directly by the computer.
• An instruction set architecture is a set of
instructions and how they work in a compute

8
Directive and instructions
• Assembler instruction generates machine
code, thus contributes towards the size of the
program .
• Assembler directive does not create any
machine code, thus does not contribute to
program size. It directs the assembler to
perform certain actions during assembly
phase

9
10
DW: Define Word.
• The DW directive serves the same purposes as
the DB directive, but it now makes the
assembler reserve the number of memory
words (16-bit) instead of bytes.
• EXample: WORDS DW 1234H

11
ORG
Directive used by assembler to define
the start address of the current machine
Internal Rate of the
code at the program memory Internal clock
clock divider
by12 pulses

Such as
0000h Machine code (INC A)

ORG 0
INC A

ORG 100h 0100h Machine code (DEC A)

DEC A

Program M 12
END
• Directive used by assembler to stop compiling.
• Any instruction after “End” consider as comment.
Internal Rate of the
clock divider Internal clock
by12 pulses

END

Any instruction after “End ” MOV A, R1


Consider as comment

Program M 13
14
instruction set architecture ISA

15
16
17
The internal clock pulse
Uses by CPU to synchronize all processes in
the microcontrollers
/12

𝑭 =𝒇 𝒄𝒓𝒚𝒔𝒕𝒂𝒍

𝒇 𝒄𝒓𝒚𝒔𝒕𝒂𝒍 18
The machine cycle (MC)

is the minimum number of CPs (in


our case12 CPs) taken by CPU to
perform a single instruction cycle
(Fetch –Decode -Execute)
What is the difference
between machine code
and machine cycle?

19
The rate of machine cycles
(The internal clock pulses)
Internal Rate of the
Crystal Oscillator Internal clock
clock divider
(Up to 24 MHz) pulses
by12

Crystal frequency
R ate of 𝑀𝑎𝑐h𝑖𝑛𝑒𝑐𝑦𝑐𝑙𝑒= [ 𝑀𝐻𝑧 ]
12

20
EXAMPLE
Calculate the rate of the internal clock pulse
of AT89C55, if the external crystal has
frequency 3 MHz
The answer

21
The Execution time
Is time taken by CPU to carry out one instruction

The Run-time (Delay-time)

Is time taken by CPU to carry out program or


subprogram

22
EXAMPLE
Calculate the total run-time (total delay time) for
AT89C51 during execution of 3 instructions that
need 1, 2 and 4 machine cycles respectively,
the connected crystal has frequency equal 6
MHz.
The answer

23
Note that:
• Port 1,2,3 have internal pull-up resistors
• Port 0 has not internal pull-up resistors

24
The internal memories of 8051

25
The internal RAM

26
The special function
27

registers
The Program-Status-Word Register (PSW)

• 4 status flags (CY, AC, OV, P)


• 2 control flags (RS0, RS1)
• User bit-addressable flag (F0)
• Reversed flag (bit1)

28
Selection of operational bank

29
The Carry and Auxiliary carry flags

Carry flag (CY) Auxiliary Carry flag (AC)


Carry up from D7 Carry up from D3  D4

D7 D6 D5 D4 D3 D2 D1 D0

Accumulator

30
The parity flag (P)

𝐛𝐢𝐭 𝟕
𝐏 = ∑ 𝐨𝐧𝐞𝐬 𝐢𝐧 𝐀𝐜𝐜𝐮𝐦𝐮𝐥𝐚𝐭𝐨𝐫
𝐛 𝐢𝐭 𝟎

Odd data  P = 1 Even data  P = 0


Or
Zero data

31
EXAMPLE
Find the status of the flags CY, AC and P
after the addition of the two digital values
ABh and 38h in AT89C51.
The answer

CY = 0 because there isn't carry-up from 8th bit of the final result.
AC = 1 because there is carry-up from 4th  5th bit of the final result.
P = 1 because the Accumulator has odd number of ones (5 ones).

32
The Over Flow flags (OV = 1) in three
cases
1) When the divisor has value zero during the division
operation.
2) When the multiplication product is greater than the value
"FFh". (the result outside the stored data in accumulator)
3) When an error occurs during the addition and subtraction
operations for the singed numbers (the result outside the
signed 8-bit range "-128" to "127").

33
EXAMPLE
Find the status of the flags CY and OV after
the addition of the two digital values F4h and
80h in the AT89C51.
The answer

-ve

-ve

+ve

34
The Internal Program memory

The PC points to the memory location to fetch


current instruction.

35

You might also like