Autosar Complete Reference
Autosar Complete Reference
1
Binary and Hexadecimal Systems
Conversion to decimal:
❍ 110.101 b = ? ❍ 110.101 b = 6.625
❍ 6A.C h = ? ❍ 6A.C h = 106.75
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
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
20
Registers
21
Tri-state Buffers
Tri-state
Transistor circuit for
inverting tri-state
buffer:
“high impedance”
(output disconnected)
Variations
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
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)
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
Data bus
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
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
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
48
Comparison of 8051 Members
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
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)
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/…
54
Atmel’s products
55