Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Designing Embedded

System with 8051


Microcontroller
UNIT IV

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Factors to be consideredin
selecting a controller
(a) Meeting the computing needs of task at hand efficiently and
cost effectively
 Speed of operation
 Feature Set
 Power consumption
 Amount of RAM and ROM on chip
 No. of I/O pins and timers on chip
 Cost
(B) Development Support: Availability of software development
tools such as compiler, assembler and debugger.
(C) How easy it is to develop products around it.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Why 8051 Microcontroller

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Why 8051 Microcontroller
• Very versatile
• Powerful Boolean processor which supports bit manipulation
• Got 6 interrupts (2: External, 2: Timer, 2: Serial)
• Two 16-bit timers/counters
• 32 I/O Lines and Programmable full duplex serial interface
• Way of handling interrupts: 2 priority levels
• Invented by Intel, today available in market from more than 20
venders
• supporting USB, SPI, TCP/IP interfaces, integrated ADC/DAC LCD
Converter and extended no. of I/O ports.
• Low cost

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


8051 MicrocontrollerIntroduction
and History Evolution
• Originally, 8051 Microcontrollers were developed using N-MOS
Technology but the use of battery powered devices and their low
power consumption lead to usage of CMOS Technology (which is
famous for its low power consumption).
• Some of the 8051 Microcontrollers produced by different
manufacturers are: Atmel (AT89C51, AT89S51), Phillips (S87C654), STC
Micro (STC89C52), Infineon (SAB-C515, XC800), Siemens (SAB-C501),
Silicon Labs (C8051), NXP (NXP700, NXP900), etc.
• Majority of the modern 8051 Microcontrollers are Silicon IP Cores
(Intellectual Property Cores) but discrete 8051 Microcontroller IC’s are
also available.
• Because of their low power consumption, smaller size and simple
architecture, 8051 IP Cores are used in FPGAs (Field Programmable
Gate Array) and SoCs (System on Chip) instead of Advanced ARM
Architecture based MCUs.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Applications of 8051
Microcontroller
• Consumer Appliances (TV Tuners, Remote controls, Computers,
Sewing Machines, etc.)
• Home Applications (TVs, VCR, Video Games, Camcorder, Music
Instruments, Home Security Systems, Garage Door Openers, etc.)
• Communication Systems (Mobile Phones, Intercoms, Answering
Machines, Paging Devices, etc.)
• Office (Fax Machines, Printers, Copiers, Laser Printers, etc.)
• Automobiles (Air Bags, ABS, Engine Control, Transmission Control,
Temperature Control, Keyless Entry, etc)
• Aeronautical and Space
• Medical Equipment
• Defense Systems
• Robotics
• Industrial Process and Flow Control
• Radio and Networking Equipment
• Remote Sensing
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
8051 Memory Organization
• The 8051 microcontroller's memory is divided into
• Program Memory and
• Data Memory.
• Program Memory (ROM) is used for permanent saving
program being executed,
• while Data Memory (RAM) is used for temporarily storing and
keeping intermediate results and variables.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Program Memory (ROM)
• Program Memory (ROM) is used for permanent saving program (CODE)
being executed.
• The memory is read only. Depending on the settings made in compiler,
program memory may also used to store a constant variables.
• The 8051 executes programs stored in program memory only. code
memory type specifier is used to refer to program memory.
• 8051 memory organization allows external program memory to be
added.
• How does the microcontroller handle external memory depends on the
pin EA logical state.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
Internal Data Memory
• Up to 256 bytes of internal data memory are available depending on
the 8051 derivative.
• Locations available to the user occupy addressing space from 0 to 7Fh,
i.e. first 128 registers and this part of RAM is divided in several blocks.
• The first 128 bytes of internal data memory are both directly and
indirectly addressable.
• The upper 128 bytes of data memory (from 0x80 to 0xFF) can be
addressed only indirectly.
• Since internal data memory is used for CALL stack also and there is only
256 bytes splited over few different memory areas fine utilizing of this
memory is crucial for fast and compact code.
• Memory block in the range of 20h to 2Fh is bit-addressable, which
means that each bit being there has its own address from 0 to 7Fh.
• Since there are 16 such registers, this block contains in total of 128 bits
with separate addresses ( Bit 0 of byte 20h has the bit address 0, and bit
7 of byte 2Fh has the bit address 7Fh).

• Three memory type specifiers can be used to refer to the internal data
memory: data, idata, and bdata.
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
External Data Memory
• Access to external memory is slower than access to internal
data memory.
• There may be up to 64K Bytes of external data memory.
Several 8051 devices provide on-chip XRAM space that is
accessed with the same instructions as the traditional external
data space.
• This XRAM space is typically enabled via proper setting of SFR
register and overlaps the external memory space.
• Setting of that register must be manually done in code,
before any access to external memory or XRAM space is
made.
• The mikroC PRO for 8051 has two memory type specifiers
that refers to external memory space: xdata and pdata.
SFR Memory
• Special Function Registers
• The 8051 provides 128 bytes of memory for Special Function
Registers (SFRs).
• SFRs are bit, byte, or word-sized registers that are used to
control
• timers,
• counters,
• serial I/O,
• port I/O, and
• peripherals.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Programming embedded
systems
• BLINKING LED PROGRAM AND INFINITE LOOP
• To blink an LED we would require the following hardware:
• LED, Resistor
• A microcontroller or microprocessor
• The LED can be connected to any available port i.e P1, P2, P3,
P4 on the microprocessor.
• Assuming the LED is connected to port 2,
• i.e. P2 its state is controlled by a bit in a register
called the Port 2 I/O Latch Register, also known the
P2LTCH

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


The structure of theprogram
• code is hardware independent hence can be implemented
for any circuit
• It contains two functions namely : toggle() & delay()
• toggle(): This function is used to toggle the state of the LED.
• delay(): This function is used to introduce a delay of 500 ms every
time the LED is toggled
• The implementation of toggle() and delay() is hardware specific.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Infinite Loop

• The code for every embedded program is written in an infinite


loop. This is because the embedded system is supposed to run
every time it is turned on till the time its power goes off or it
stops functioning.
• The code for blinking LED is also enclosed in an infinite loop. The
functions toggle() and delay() run infinite number of times.
• An application of an embedded system has an infinite loop
around its code. It’s just like the program you did to implement
switch case where the program has to run continuously until the
user selects to exit.

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


BUILD PROCESS INEMBEDDED
SYSTEM
• Definition: The process which converts source code to executable code
is called as the build process.

• An Embedded system would also use tools such as a Compiler, Linker,


Locater and Debugger to perform the entire build process.
• These tools would be a part of a larger IDE.

• A compiler which produces the executable code to be run on a


different platform is called a cross-compiler; else it is called a native
compiler.

• The build process involves three steps:


• 1. Compiling
• 2. Linking
• 3. Locating
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
Build Process inEmbedded
System

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Build Process inEmbedded
System

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Compiling
• The process of compiling is done by the compiler.
• The compiler takes input as source code files and gives
output as multiple object files.
• Compilers for embedded systems are essentially cross-
compilers.
• For example while compiling the programmer has to select the
target processor for which the code has to be generated.
• The contents of the object files depend on its format. Two
• commonly used formats are:
• 1. Common Object file format (COFF)
• 2. Extended file format (ELF)

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Compiling
• Object files generally have the following structure

Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi


Linking & Debugging
• The process of linking is carried out by the linker
• The linker takes input as multiple object files and gives output as a
single object file which is also called as the re-locatable code.
• The output of compiler is multiple object files. These files are incomplete in
the sense that they may contain reference to variables and functions across
multiple object files which need to be resolved.
• The job of the linker is to combine these multiple object files and
resolve the unresolved symbols.
• The Linker does this by merging the various sections like text, data, and
bss of the individual object files.
• The output of the linker will be a single file which contains all of the
machine language code from all of the input object files that will be in the
text section of this new file, and all of the initialized and uninitialized variables
will reside in the new data section and bss section respectively.
• Debugging an embedded system is similar to debugging a host based
application. Many embedded systems are not possible to debug unless they
are operating at full speed. Hence debugging of an embedded system uses
host computer
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi
Locating
• The process of relocating is carried out by the relocater.

• The relocater takes input as the relocatable code produced by


the linker and gives output as the final executable code.

• This output is a binary executable file which is called hex code.


• The locator needs to be given information about the memory
available on the target processor.

• The locator will use this information to assign physical memory


addresses to each of the code and data sections within the
relocatable program code.

• Finally it produces an output file that contains a binary memory


image that can be loaded into the target processors ROM.
Prepared by Mrs. Trupti Kulkarni Kaujalgi, ICLES' M J College, Vashi

You might also like