Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
18 views

Module 1 Notes

The document compares microprocessors and microcontrollers. It states that microprocessors are general purpose devices that require external RAM, ROM, I/O ports and timers to function, while microcontrollers integrate these components. Microcontrollers are ideal for applications where cost and space are critical factors over computing power. The document also provides examples of embedded systems and discusses characteristics of the popular 8051 microcontroller such as its architecture, programming model, and memory organization.

Uploaded by

SANATH BHAT S M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Module 1 Notes

The document compares microprocessors and microcontrollers. It states that microprocessors are general purpose devices that require external RAM, ROM, I/O ports and timers to function, while microcontrollers integrate these components. Microcontrollers are ideal for applications where cost and space are critical factors over computing power. The document also provides examples of embedded systems and discusses characteristics of the popular 8051 microcontroller such as its architecture, programming model, and memory organization.

Uploaded by

SANATH BHAT S M
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Comparison of Microprocessors and Microcontrollers

Embedded Systems:
Microprocessor is a general-purpose device. These microprocessors contain no
RAM, no ROM, and no I/O ports on the chip itself.

General-purpose microprocessors based system:


1. Must add RAM, ROM, I/O ports, and timers externally to make them functional
2. Make the system bulkier and much more expensive
3. Have the advantage of versatility on the amount of RAM, ROM, and I/O ports

Microcontroller has
1. CPU (microprocessor)
1. RAM
2. ROM
3. I/O ports
4. Timer
5. ADC and other peripherals
Microcontroller has
· The fixed amount of on-chip ROM, RAM, and number of I/O ports makes them ideal
for many applications in which cost and space are critical
· In many applications, the space it takes, the power it consumes, and the price per
unit are much more critical considerations than the computing power

An embedded product uses a microprocessor (or microcontroller) to do one task and one
task only. There is only one application software that is typically burned into ROM

A PC, in contrast with the embedded system, can be used for any number of applications:
· It has RAM memory and an operating system that loads a variety of applications into
RAM and lets the CPU run them
· A PC contains or is connected to various embedded products. Each one peripheral has
a microcontroller inside it that performs only one task.

Examples for embedded systems are:


· Home
o Appliances, intercom, telephones, security systems, garage door openers,
answering machines, fax machines, home computers, TVs, cable TV tuner, VCR,
camcorder, remote controls, video games, cellular phones, musical
instruments, sewing machines, lighting control, paging, camera, pinball
machines, toys, exercise equipment
· Office
o Telephones, computers, security systems, fax machines, microwave, copier,
laser printer, color printer, paging
· Auto
o Trip computer, engine control, air bag, ABS, instrumentation, security system,
transmission control, entertainment, climate control, cellular
phone, keyless entry

Embedded Microcontrollers:
General-purpose microprocessors have targeted their microprocessor for the high end of the
embedded market whenever a microcontroller is inadequate for the task. When a company
targets a general purpose microprocessor for the embedded market, it optimizes the
processor used for embedded systems. Very often the terms embedded processor and
microcontroller are used interchangeably.

x86 PC Embedded Applications:

· One of the most critical needs of an embedded system is to decrease power


consumption and space.
· In high-performance embedded processors, the trend is to integrate more functions
on the CPU chip and let designer decide which features wants to use.
· In many cases use of x86 PCs for the high-end embedded applications is feasible
o Saves money and shortens development time
§ A vast library of software already written
§ Windows is a widely used and well understood platform

Choosing a Microcontroller:
In market microcontroller are available with different sizes.
Ex:
Popular 8-bit microcontrollers are
· Motorola’s 6811
· Intel’s 8051
· Zilog’s Z8
· Microchip’s PIC
There are also 16-bit and 32-bit microcontrollers made by various chip makers.

Criteria for Choosing a Microcontroller:


· Meeting the computing needs of the task at hand efficiently and cost effectively.
Following parameter to be satisfied based on the requirement.
o Speed
o Packaging
o Power consumption
o The amount of RAM and ROM on chip
o The number of I/O pins and the timer on chip
o How easy to upgrade to higher performance or lower power-consumption
versions
o Cost per unit
· Based on Availability of software development tools, such as compilers, assemblers,
and debuggers.
· Wide availability and reliable sources of the microcontroller
o The 8051 family has the largest number of diversified (multiple source)
suppliers
§ Intel (original)
§ Atmel
§ Philips/Signetics
§ AMD
§ Infineon (formerly Siemens)
§ Matra
§ Dallas Semiconductor/Maxim
8051Architecture:

Intel introduced 8051, referred as MCS-51, in 1981. The 8051 is an 8-bit processor. The
CPU can work on only 8 bits of data at a time.

Salient features of 8051 microcontroller are given below.


· Eight bit CPU
· On chip clock oscillator
· 4Kbytes of internal program memory (code memory) [ROM]
· 128 bytes of internal data memory [RAM]
· 64 Kbytes of external program memory address space.
· 64 Kbytes of external data memory address space.
· 32 bi directional I/O lines (can be used as four 8 bit ports or 32 individually
addressable I/O lines)
· Two 16 Bit Timer/Counter :T0, T1
· Full Duplex serial data receiver/transmitter
· Four Register banks with 8 registers in each bank.
· Sixteen bit Program counter (PC) and a data pointer (DPTR)
· 8 Bit Program Status Word (PSW)
· 8 Bit Stack Pointer
· Five vector interrupt structure (RESET not considered as an interrupt.)
· 8051 CPU consists of 8 bit ALU with associated registers like accumulator ‘A’ , B
register, PSW, SP, 16 bit program counter, stack pointer.
· ALU can perform arithmetic and logic functions on 8 bit variables.
· 8051 has 128 bytes of internal RAM which is divided into
o Working registers [00 – 1F]
o Bit addressable memory area [20 – 2F]
o General purpose memory area (Scratch pad memory) [30-7F]
The 8051 became widely popular after allowing other manufactures to make and
market any flavor of the 8051, but remaining code-compatible

Aarchitecture of 8051
The microcontroller has CPU, ROM, Interrupt control circuit, internal timing devices (timers
T0, T1), serial interface (SI), RAM and special function registers (SFRs). It has four ports P0,
P1, P2 and P3.
The above figure shows the usual CPU components: program counter, ALU, working
registers, and clock circuits.
The 8051 architecture consists of these specific features:
· Eight-bit CPU with registers A (the accumulator) and B
· Sixteen-bit program counter (PC) and data pointer (DPTR). DPTR register is made
up of two 8-bit registers, named DPH and DPL, that are used to furnish memory
addresses for internal and external code access and external data access.
· Eight-bit program status word (PSW)
· Eight-bit stack pointer (SP)
· Internal ROM or EPROM of 0 to 4K.
· Internal RAM of 128 bytes:
· Four register banks, each containing eight registers
· Sixteen bytes, which may be addressed at the bit level Eighty bytes of general
purpose data memory
· Thirty-two input/output pins arranged as four 8-bit ports: P0-P3
· Two 16-bit timer/counters: TO and T1
· Full duplex serial data receiver/transmitter: SBUF
· Control registers: TCON, TMOD, SCON, PCON, IP, and IE
· Two external and three internal interrupt sources
· Oscillator and clock circuits

The Programming Model

The programming model of the 8051 shows the collection of 8- and 16-bit registers and 8-
bit memory locations. These registers and memory locations can be made to operate using
the software instructions that are incorporated as part of the design. The program
instructions have to do with the control of the registers and digital data paths that are
physically contained inside the 8051, as well as memory locations that are physically
located outside the 8051.

Program Status Word (PSW):


The 8051 has four math flags that respond automatically to the outcomes of math
operations and three general-purpose user flags that can be set to I or cleared to 0 by the
programmer as desired. The math flags include carry (C), auxiliary carry (AC), overflow
(OV), and parity (P). User flags are named F0, GFO, and GF1; they are general-purpose
flags that may be used by the programmer to record some event in the program. Note that
all of the flags can be set and cleared by the programmer at will. The math flags, however,
are also affected by math operations.
Pin diagram:
The 8051 Oscillator and Clock
• Clock is used to synchronize all operations.
• Pins XTAL1 and XTAL2 connects to resonant circuit to form an oscillator.
• 8051 designs can run at maximum and minimum frequencies.
• Typically 1MHz to 16MHz.
• Internal memories are dynamic and must always operate above minimum
frequency.
• Ceramic resonators are used as a low cost alternative to crystal resonators.
• Clock frequency (f), with smallest interval of time within microcontroller called the
pulse (P).
• Tinst =
_
• C= number clock cycles per instruction
• Typically 11.0592 MHz crystal is used to generate baudrates of 19200, 9600, 4800,
2400, 1200
• Internal counters must divide the basic clock rate to yield standard communication
bit per second rates(Baud rates)
Internal Memory organization.
Internal RAM: Size of the Internal RAM is bytes.

Register Banks: 00h to 1Fh. The 8051 uses 8 general-purpose registers R0 through R7
(R0, R1, R2, R3, R4, R5, R6, and R7). There are four such register banks. Selection of
register bank can be done through RS1,RS0 bits of PSW. On reset, the default Register Bank
0 will be selected.
Bit Addressable RAM: 20h to 2Fh . The 8051 supports a special feature which allows
access to bit variables. This is where individual memory bits in Internal RAM can be set or
cleared. In all there are 128 bits numbered 00h to 7Fh. Being bit variables any one variable
can have a value 0 or 1. A bit variable can be set with a command such as SETB and cleared
with a command such as CLR. The Bit Addressable area of the RAM is just 16 bytes of
Internal RAM located between 20h and 2Fh.
General Purpose RAM: 30h to 7Fh. Even if 80 bytes of Internal RAM memory are
available for general-purpose data storage, user should take care while using the memory
location from 00 -2Fh since these locations are also the default register space, stack space,
and bit addressable space. It is a good practice to use general purpose memory from 30 –
7Fh. The general purpose RAM can be accessed using direct or indirect addressing modes
Stack Memory:
The stack is a section of RAM used by the CPU to store information temporarily. This
information could be data or an address. The register used to access the stack is called the
SP (stack pointer) register. The stack pointer in the 8051 is only 8 bit wide, which means
that it can take value of 00 to FFH. Special instructions are used to access stack memory Stack
pointer register is used to hold the internal RAM called “top of the stack”. Address in the SP
is location to which data is stored last SP increments before storing the data SP decrements
after retrieving the data.
SFR: Special Function Registers
• SFR are addressed by 80h to FFh. Not all addresses are used.
• Some SFR are bit addressable.
• SFR are used in opcodes by specifying its functional name

Internal ROM:
Program code, is stored in an internal ROM, and occupies code address space OOOOh to
OFFFh. The PC is ordinarily used to address program code bytes from addresses OOOOh to
FFFFh . Program addresses higher than OFFFh, which exceed the internal ROM capacity, will
cause the 8051 to automatically fetch code bytes from external program memory. Code bytes
can also be fetched exclusively from an external memory, addresses OOOOh to FFFFh, by
connecting the external access pin ( pin 31 on the DIP) to ground. The PC does not care
where the code is; the circuit designer decides whether the code is found totally in internal
ROM, totally in external ROM, or in a combination of internal and external ROM.

I/O ports functions


• 32 pins available to connect external world to 8051 using I/O circuitry
• 24 Pins can perform one of two entirely different operations
• External memory, parallel ports and serial communication can be included
• Consists of D-type latch for each port pin and addressed using SFR address
• For I/O ports with 8 pins each: Port 0, Port 1, Port 2, Port 3
• Port 1 does not have alternate function
External Memory (ROM & RAM) interfacing:
• System design is limited by Internal memory
• Two separate external memory: RAM and ROM accessed using DPTR and PC
respectively
• Use of RAM or ROM: Machine cycle state and opcode being executed
• pin is connected to ground or PC contains higher than 0FFFh address
• Memory access of ROM: will go low to enable ROM.
• Memory access of RAM: or will go low to enable write or read data
Interfacing 8Kx8-bit RAM to 8051
Timers/Counters, Serial
Communication, Interrupts
Counters
• Timers can also be used as counters counting events happening outside the
8051
• When it is used as a counter, it is a pulse outside of the 8051 that increments the
TH, TL registers
• TMOD and TH, TL registers are the same as for the timer discussed previously
• The C/T bit in the TMOD registers decides the source of the clock for the timer
• When C/T = 1, the timer is used as a counter and gets its pulses from outside the 8051
• The counter counts up as pulses are fed from pins 14:P3.4(RXD) and 15:P3.5(TXD),
these pins are called T0 (timer 0 input) and T1 (timer 1 input)
Serial Data Input/Output
Computers transfer data in two ways:
Parallel
• Often 8 or more lines (wire conductors) are used to transfer data to a device that is only a
few feet away
Serial
• To transfer to a device located many meters away, the serial method is used
• The data is sent one bit at a time
SBUF register
• SBUF is an 8-bit register used solely for serial communication
• For a byte data to be transferred via the TxD line, it must be placed in
the SBUF register
• The moment a byte is written into SBUF, it is framed with the start and stop
bits and transferred serially via the TxD line
• SBUF holds the byte of data when it is received by 8051 RxD line
• When the bits are received serially via RxD, the 8051 deframes it by
eliminating the stop and start bits, making a byte ou/t of the data received,
and then placing it in SBUF
SCON Register
• SCON is an 8-bit register used to program the start bit, stop bit, and
data bits of data framing, among other things
PCON register
• Serial data flags RI and TI in SCON sets when a data byte is Received
or transmitted
• TI an RI Ored together to produce an interrupt
• Program should find out which caused the interrupt and should be
cleared by the program
Data Transmission
• Put data byte in SBUF to be transmitted
• When TI=1, data transmission is completed
• Ready to transmit another byte

Data Reception
• Data byte will be received in SBUF if Receive enable bit(REN) is set
• RI is cleared in Mode 0
• When RI=1, data Reception is completed
• RI= 0 for Mode 0 prevents the reception of new data until the program has dealt with
old data is being received
• MODE 1/2/3: when RI= 1 data reception can start
• RI Should be cleared before the last bit reception
Serial MODE 0
• SCON: SM1 and SM0 should have 00
• SBUF: holds Received byte or a byte to be transmitted through RXD
• Used for high speed serial data-collection method using discrete logic
to achieve high data rates
Serial Data Mode 1—Standard UART
• SMO and SMI are set to 01b,
• SBUF becomes a 10-bit full-duplex receiver/transmitter
• RXD receives all data and TXD transmits ail data.
• Transmitted data: start bit, eight data bits (Least Significant Bit, LSB, first), and a stop bit.
• TI is set when all ten bits have been sent.
• Each bit interval is the inverse of the baud rate frequency,
• Each bit is maintained high or low over that interval.
• Reception is triggered by the falling edge of the start bit and continues if the stop bit is true (0 level) halfway
through the start bit interval.
Serial Data Mode 2—Multiprocessor Mode
• Mode 2 is similar to mode 1 except 11 bits are transmitted: a start bit, nine data
bits, and a stop bit
• The ninth data bit is gotten from bit TB8 in SCON during transmit and stored in bit
RB8 of SCON when data is received. Both the start and
stop bits are discarded.
• The baud rate is much higher than standard communication rates. This high data
rate is needed in many multi-processor applications
• Mode 3 is identical to mode 2 except that the baud rate is determined exactly as
in mode 1, using Timer 1 to generate communication frequencies.
Interrupts
• A computer program has only two ways to determine the conditions
that exist in internal and external circuits.
• One method uses software instructions that jump on the states of
flags and port pins.
• The second responds to hardware signals, called interrupts, that force
the program to call a sub-routine.
• Software techniques use up processor time that could be devoted to
other tasks; interrupts take processor time only when action by the
program is needed.

You might also like