0% found this document useful (0 votes)
120 views55 pages

Autosar Complete Reference

The document provides an introduction to computing and 8051 microcontrollers. It discusses binary and hexadecimal number systems, two's complement representation of signed numbers, ASCII encoding, logic gates, flip-flops, registers, buses, and the stored program concept in computer architecture. Key topics include data representation schemes, basic logic components, memory elements, and the functioning of the central processing unit, memory, and input/output components in a stored program computer.

Uploaded by

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

Autosar Complete Reference

The document provides an introduction to computing and 8051 microcontrollers. It discusses binary and hexadecimal number systems, two's complement representation of signed numbers, ASCII encoding, logic gates, flip-flops, registers, buses, and the stored program concept in computer architecture. Key topics include data representation schemes, basic logic components, memory elements, and the functioning of the central processing unit, memory, and input/output components in a stored program computer.

Uploaded by

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

Week 1

Introduction to Computing and


the 8051 Microcontrollers
Chapters 0 and 1

1
Binary and Hexadecimal Systems
‰ Conversion to decimal:
❍ 110.101 b = ? ❍ 110.101 b = 6.625
❍ 6A.C h = ? ❍ 6A.C h = 106.75

‰ Conversion from decimal


❍ for a whole number: divide by the
radix and save the remainder as
the significant digits
❍ 10 = 1010 b
❍ 10 = ? B
❍ 10 = ? 8 ❍ 10 = 12 8
‰ Converting from a decimal
fraction
❍ multiply the decimal fraction by
the radix
❍ save the whole number part of
0.125 = 0.001 b
the result ❍
❍ 0.046875 = 0.0C h
❍ repeat above until fractional part
of step 2 is 0
❍ 0.125 = ? b
❍ 0.046875 = ? h
2
Base 16 Number systems
❒ Represent 100111110101b in hex
Group them
1001 1111 0101
9 F 5 hex

❒ Convert 1714d to binary


1714 = 16*107 +2
107 = 16*6 + 11
1714 = 6B2 h
= 0110 1011 0010 b

3
Two’s Complement
‰ If the number is positive make no changes
‰ If the number is negative, complement all bits and add by 1
❍ -6 => 0000 0110 + 1 = 1111 1001 + 1 = FAh
‰ 8 bit signed numbers
❍ 0 to 7Fh (+127) are positive numbers
❍ 80h (-128)to FFh (-1) are negative numbers
‰ Conversion of signed binary numbers to their decimal equivalent
❍ 1101 0001
• 1101 0001 + 1 = 0010 1110 + 1 = 0010 1111 = 2Fh => -47
❍ 1000 1111 0101 1101
• 0111 0000 1010 0010 + 1 = 0111 0000 1010 0011 = 70C3h => -28835
‰ Two’s complement arithmetic
❍ +14 - 20
❍ 0000 1110 + 0001 0100 + 1 = FAh
‰ Overflow: Whenever two signed numbers are added or subtracted
the possibility exists that the result may be too large for the
number of bits allocated Ex: +64 +96 using 8-bit signed numbers
4
Two’s complement
Decimal Binary Hex
-128 1000 0000 b 80h
-127 1000 0001b 81h
-126 1000 0010b 82h
… …
-2 1111 1110b FEh
-1 1111 1111b FFh
0 0000 0000b 00h
1 0000 0001b 01h
… …
+127 0111 1111b 7Fh

Numbers in the range -2^n … 2^n –1


are represented by 8 bit signed arithmetic
5
ASCII
‰ The standard for text
‰ In this code each letter of the alphabet,
punctuation mark, and decimal number is
assigned a unique 7-bit code number
‰ With 7 bits, 128 unique symbols can be
coded
‰ Often a zero is placed in the most
significant bit position to make it an 8-bit
code
❍ e.g., Uppercase A 41h
‰ Digits 0 through 9 are represented by
ASCII codes 30h to 39h 6
ASCII - more

7
BCD
‰ BCD code provides a way for decimal numbers to be
encoded in binary form that is easily converted back
to decimal
❍ 26 => 0010 0110 (BCD) => 11010 (unsigned binary)
❍ 243 => 0010 0100 0011 (BCD) => 1111 0011 (unsigned binary)
‰ Used in seven segment displays

8
Digital Primer

Inversion

9
AND and OR Gates

10
XOR Gate

11
Logic Design using Gates
‰ Two implementations of a half-adder

12
Full adder using half adders

13
3-bit adder using 3 full-adders

14
Multiplexer

15
N to 2N Decoder

16
Address decoders

17
Latch
‰ The simplest memory element
‰ Level-sensitive: it memorizes the input data when there is a
given level on the control input

18
D type flip flop (DFF)
‰ The only Flip-Flop we use (forget SR, JK, etc.)
‰ The most used memory element
‰ Edge-sensitive: it memorizes the input data when there is a
specific transition (e.g., 0 Æ 1) on the control input

19
DFF with Enable

‰ If EN = 0 when there is an edge, the edge


is ignored;
‰ If EN = 1, normal behaviour

20
Registers

21
Tri-state Buffers
‰ Tri-state
‰ Transistor circuit for
inverting tri-state
buffer:
“high impedance”
(output disconnected)

‰ Variations

Inverting buffer Inverted enable “transmission gate”

22
Tri-state Buffers
Tri-state buffers are used when multiple circuits all connect to a common bus.
Only one circuit at a time is allowed to drive the bus. All others “disconnect”.

‰ Bidirectional ‰ Busses:
connections:

23
Inside the Computer

24
Inside the Computer - More

25
Stored Program concept

26
Stored Program Concept
‰ There are three major parts
❍ The CPU (Central Processing Unit) which acts as the
brain coordinating all activities within the computer
❍ The memory unit where the program instructions and
data are temporarily stored
❍ The I/O (Input/Output) devices which allow the
computer to input information for processing and then
output the result
‰ Today the CPU circuitry has been reduced to ICs
called the microprocessor, the entire computer
with the three parts is called a microcomputer

27
Stored Program Concept - more
‰ Several registers (e.g., flip-flops wired in series
with each other)
❍ Some are general purpose, the accumulator for example
is reserved for performing complex mathematical
operations like multiply and divide, and all I/O data has
to go thru the accumulator
‰ The basic timing of the computer is controlled by
a square wave oscillator or a clock generator
circuit.
❍ Synchronization
❍ Determines how fast the program can be fetched from
memory and executed
‰ Memory Read or Fetch Cycle
❍ IP: Instruction Pointer
28
Stored Program Concept
‰ Memory unit consists of a large number of
storage locations each with its own address
❍ RAM (Random Access Memory) and its volatility
• Typically each memory location is 8 bits wide (byte
accessible memory)
❍ ROM (Read Only Memory)
‰ The memory unit’s address
selector/decoder circuit examines the
binary number on the address line and
selects the proper memory location to be
accessed.

29
Stored Program Concept
‰ In this example, CPU is reading from memory, it
activates its MEMORY READ control signal
❍ This causes the selected data byte in memory to be
placed onto the data lines and routed to the instruction
register in the CPU
‰ Once in the CPU, the instruction is decoded and
executed
❍ In this example, instruction has the decimal code 64
which for a 8086 microprocessor is decoded to be INC
AX
❍ The ALU (Arithmetic Logic Unit) is instructed to add 1 to
the contents of the AX
‰ The cycle repeats itself

30
Stored Program Concept

‰ Memory unit consists of a large number of


storage locations each with its own address.
‰ RAM (Random Access Memory): also called
read/write memory
❍ used for temporary storage of programs
❍ typically 8 bits wide
❍ data is lost when the power is turned off (volatile)

‰ ROM (Read Only Memory)


❍ The information in ROM is permanent
❍ Non-volatile memory
31
Three Bus System Architecture
‰ A collection of electronic signals all dedicated to particular task
is called a bus
❍ address bus
❍ data bus
❍ control bus
‰ Data Bus
❍ The width of the data bus determines how much data the processor
can read or write in one memory or I/O cycle
❍ 8-bit microprocessor has an 8-bit data bus
❍ 80386SX 32-bit internal data bus, 16-bit external data bus
❍ 80386 32-bit internal and external data buses
‰ How can a 64-bit (or 16 bit) microprocessor access an 8-bit
memory?
❍ The trick is to divide the memory into banks
❍ 64-bit Pentium requires eight banks of memory with each bank set
up to be one-byte wide
❍ Bank enable signals are then output by the microprocessor to
specify which bank to access
32
Address Bus
‰ Address Bus
❍ The address bus is used to
identify the memory location or
I/O device (also called port) the
processor intends to
communicate with
Total amount
❍ 20 bits for the 8086 and 8088
of memory is 4Mbytes
❍ 32 bits for the 80386/80486
and the Pentium
❍ 36 bits for the Pentium II and 8086 has a 20-bit address bus and
III therefore addresses all
❍ The total number of memory combinations of addresses from all
locations addressable by a given 0s to all 1s. This corresponds to 2
CPU is always equal to 2^x 20 addresses or 1M (1 Meg)
where x is the number of
address bits, regardless of the addresses or memory locations.
data bus. Pentium: 4Gbyte main memory

33
Control Bus
‰ How can we tell the address is a memory address
or an I/O port address
❍ Memory Read
❍ Memory Write
❍ I/O Read
❍ I/O Write
‰ When Memory Read or I/O Read are active, data
is input to the processor.
‰ When Memory Write or I/O Write are active,
data is output from the processor.
‰ The control bus signals are defined from the
processor’s point of view.
‰ Control and address lines are output lines only but
the data bus is bidirectional 34
Some Important Terminology
‰ Bit is a binary digit that can have the value 0 or 1
‰ A byte is defined as 8 bits
‰ A nibble is half a byte
‰ A word is two bytes
‰ A double word is four bytes
‰ A kilobyte is 2^10 bytes (1024 bytes), The
abbreviation K is most often used
❍ Example: A floppy disk holding 356Kbytes of data
‰ A megabyte or meg is 2^20 bytes, it is exactly
1,048,576 bytes
‰ A gigabyte is 2^30 bytes

35
Internal Working of Computers
‰ Assume that an imaginary CPU has registers called A,B,C, D.
‰ It has an 8-bit data bus and a 16-bit address bus.
‰ Therefore the CPU can access memory from addresses
0000h to FFFFh for a total of 2^16 locations
‰ The action to be performed by the CPU is to put a
hexadecimal value 21 into register A, and add to register A
values 42h and 12h.
‰ Assume that the code for the CPU to move a value to
register A is 1011 0000b (B0h) and the code for adding a
value to register A is 0000 0100b (04h)

Action Code Data


Move 21h to A B0h 21h
Add 42h to A 04h 42h
Add 12h to A 04h 12h 36
Example Continued
Memory Address Content of memory
1400h B0h
1401h 21h
1402h 04h
1403h 42h
1404h 04h
1405h 12h
1406h F4h (the code for halt)

‰ Assume program is stored at memory


locations starting at 1400h 37
Internal Working Of Computers
ACTION Code Data
Move value 21 into register A B0H 21H
Add value 42H to register A 04H 42H
Add value 12H to register A 04H 12H
Memory Address Contents of memory address
1400 (B0) the code for move to A
1401 (21) the value for A
1402 (04) the code for adding a value to A
1403 (42) the value to be added
1404 (04) the code for adding a value to A
1405 (12) the value to be added
1406 (F4) the code for halt

38
Internal Working Of Computers
1- the CPU program counter can have any value between
0000 Æ FFFF H. This one is set to start with 1400

2- the CPU puts out 1400. The memory circuitry finds the
location. Activates the read signal, indicating the memory
location 1400. B0 is put on the bus and brought to the CPU

MEM
PC=1400
Read
CPU
Inst Decoder
B0
B0 decode

3- B0 is decoded internally it now knows it needs to fetch the


next byte!. It brings 21h from 1401. The program counter
automatically increments itself to the next location to fetch
the next data/instruction.
39
General Purpose Microprocessors
Microprocessors lead to versatile products

Data bus

CPU General Serial


Purpose RAM ROM I/O Timer COM
Microprocessor Port

Address bus
• These general microprocessors contain no RAM,
ROM, or I/O ports on the chip itself
• Ex. Intel’s x86 family (8088, 8086, 80386, 80386,
80486, Pentium)
• Motorola’s 680x0 family (68000, 68010, 68020, etc) 40
Microcontrollers
• Examples
CPU RAM ROM • Motorola’s 6811,
Intel’s 8051,
Zilog’s Z8 and
Serial Com PIC 16X
I/O TIMER Port

• A microcontroller has a CPU in addition to a fixed


amount of RAM, ROM, I/O ports on one single chip; this
makes them ideal for applications in which cost and
space are critical
• Example: a TV remote control does not need the
computing power of a 486 41
Microprocessor vs microcontroller

Microprocessor Microcontroller
‰ CPU is stand-alone, ‰ CPU, RAM, ROM, I/O
RAM, ROM, I/O, timer and timer are all on a
are separate single chip
‰ Designer can decide on ‰ Fix amount of on-chip
the amount of ROM, ROM, RAM, I/O ports
RAM and I/O ports. ‰ Single-purpose
‰ General-purpose ‰ Inexpensive
‰ Expensive ‰ For applications in
which cost, power and
space are critical

42
Embedded Systems
‰ Embedded system means the processor is
embedded into that application.
‰ An embedded product uses a microprocessor or
microcontroller to do one task only.
‰ In an embedded system, there is only one
application software that is typically burned into
ROM.
‰ Table 1-1, some embedded products using
microcontrollers. Examples: printer, keyboard,
video game player, door opener, copier, ABS, fax
machine, camera, cellular phone, keyless entry,
microwave...

43
Embedded Systems
‰ Although microcontrollers are the preferred
choice for embedded systems, there are times
that the microcontroller is inadequate for the
task
‰ Intel, Motorola, AMD, Cyrix have also targeted
the embedded market with their general purpose
microprocessors
‰ For example, Power PC microprocessors (IBM
Motorola joint venture) are used in PCs and
routers/switches today
‰ Microcontrollers differ in terms of their
RAM,ROM, I/O sizes and type.
❍ ROM: One time-programmable, UV-ROM, flash memory
44
Embedded Systems - more
‰ Which is your choice for an embedded
product?
‰ microcontroller
❍ cost down
❍ embedded processor or microcontroller

‰ microprocessor
❍ In future, an entire computer on a chip
❍ high-end embedded systems use
microprocessors
❍ Advantage: rapid software development, all
(appliances) in one.

45
How to choose a microcontroller

1. meeting the computing needs of the task


efficiently and cost effectively
• speed, the amount of ROM and RAM, the number of
I/O ports and timers, size, packaging, power
consumption
• easy to upgrade
• cost per unit
2. availability of software development tools
• assemblers, debuggers, C compilers, emulator,
simulator, technical support
3. wide availability and reliable sources of the
microcontrollers.

46
Intel 8051
‰ 1981, Intel MCS-51
‰ The 8051 became popular after Intel
allowed other manufacturers to make and
market a flavor of the 8051.
❍ different speed, amount of on-chip ROM
❍ code-compatible with the original 8051
❍ form a 8051 family

47
8051 Features

Feature Quantity Notes


ROM 4K bytes a fixed program
RAM 128 bytes temporary data
Timers 2 Timer/counter
0,1
I/O pins 32 P0,P1,P2,P3
Serial port 1 TxD, RxD
Interrupt sources 6

48
Comparison of 8051 Members

Table 1-4 Comparison of the 8051 Family Members


Feature 8051 8052 8031
ROM (program space in bytes) 4K 8K 0
RAM (bytes) 128 256 128
Timers 2 3 2
I/O pins 32 32 32
Serial port 1 1 1
Interrupt sources 6 8 6

❒ 8031 is referred as ROM-less 8051


❒ To use ROM you must add external ROM to
it but you lose two ports

49
8051 Layout
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3
P1.4
4
8051 37 P0.2(AD2)
P0.3(AD3)
5 36
P1.5 6 (8031) 35 P0.4(AD4)
P1.6 7 34 P0.5(AD5)
P1.7 8 33 P0.6(AD6)
RST 9 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
50
8051 Block Diagram
4K bytes
(max: 64K)
External interrupts
On-chip 128 bytes Timer/Counter

Interrupt ROM for


On-chip Timer 1
Control program
RAM Timer 0
code

CPU

Bus Serial
4 I/O Ports
OSC Control Port

P0 P1 P2 P3 TxD RxD
4 I/O ports
Address:P0,P2
Figure 1-2. Inside the 8051 Microcontroller Block Diagram
51
Max Erase Cost (per
Type Volatile? Writeable? Erase Size Speed
Cycles Byte)

SRAM Yes Yes Byte Unlimited Expensive Fast

DRAM Yes Yes Byte Unlimited Moderate Moderate

Masked
No No n/a n/a Inexpensive Fast
ROM
Once, with a
device
PROM No
programm
n/a n/a Moderate Fast
er
Yes, with a
device Limited (consult
EPROM No
programm
Entire Chip
datasheet)
Moderate Fast
er

Fast to read,
Limited (consult
EEPROM No Yes Byte
datasheet)
Expensive slow to
erase/write

Fast to read,
Limited (consult
Flash No Yes Sector
datasheet)
Moderate slow to
erase/write

Expensive
NVRAM No Yes Byte Unlimited (SRAM + Fast
battery)
52
Different 8051 Products
‰ Distinguish by types of ROM:
4k bytes UV-EPROM, PROM
‰ 8751 microcontroller burner, UV-EPROM eraser
‰ AT89C51 from Atmel Corporation flash memory, PROM
burner only
‰ DS89C4x0 from Dallas Semiconductor
flash memory, r/w
from/to COM port
‰ DS5000 from Dallas Semiconductor NV-RAM, r/w from/to PC
serial port
‰ OTP (one-time-programmable) version of the 8051
for large market
‰ 8051 family from Philips

‰ Note
❍ Memory is the biggest difference between them; see
Chapters 14 and Chapter 15.
53
DS89C420/430/…

In the lab experiments, we’ll use the MDE8051


trainer which uses the Dallas (now part of Maxim)
DS89C420/430.

54
Atmel’s products

55

You might also like