Download Standard single purpose processors

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Control theory wikipedia , lookup

Resilient control systems wikipedia , lookup

Variable-frequency drive wikipedia , lookup

Distributed control system wikipedia , lookup

Opto-isolator wikipedia , lookup

Electronic engineering wikipedia , lookup

Microprocessor wikipedia , lookup

Hendrik Wade Bode wikipedia , lookup

Time-to-digital converter wikipedia , lookup

Control system wikipedia , lookup

Stepper motor wikipedia , lookup

Public address system wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Pulse-width modulation wikipedia , lookup

Embedded system wikipedia , lookup

Transcript
Standard single-purpose
processors
DONE BY:
MUNA & RASHA
SUPERVISED BY:
DR. LO’AI TAWALBEH
Outline
2
Introduction
Timer
Counter
Watchdog
UART, USART, DUART
PWM
LCD Controller
Keypad Controller
Stepper Motor
ADC & DAC
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Introduction
3
Processors
Generalpurpose
Singlepurpose
Custom
Standard
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
4
Generalpurpose
Singlepurpose
Many computational tasks , large variety of applications
Specific computational task
Standard
Specific computational task ,wide variety of applications
Custom
Specific computational task , particular application
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Standard single-purpose processors
5



Known as Peripherals . (exist on the periphery of the CPU)
“Off-the shelf”  pre-designed for a common task.
Embedded system designers use standard singleprocessor rather than general-purpose processor to achieve
the following benefits:
Fast performance
 Fewer clock cycles .
 Shorter cycles .
 Small size
 No program memory .
 Small instruction set
 Simple datapath and controller .
 Low unit cost

"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Tradeoffs !!!!
6
 If we are already using a general-purpose processor, then
implementing a task on an additional single-purpose
processor rather than in software may add to the
system size and power consumption.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Timer
7
 A device that generates a signal pulse at specified
time intervals .
 Mainly consist of a register, counter, and an
extremely simple controller.
Number of clock cycles = Desired real-time value / Clock cycle
 Example: how many clock cycles needed to obtain a
duration of 3 μs from a clock cycle of 100 MHz ?

(3x10-6 / 10x10-9 ) = 300 cycles
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
8
 The register holds a count value
How timer
works?

Basic timer
Clk

16-bit up counter
16
Cnt
Top


(number of clock cycles).
The counter is initially loaded with
the count value.
It counts down on every clock cycle .
When zero is reached; an output
signal is generated .
The count value is reloaded, and the
process repeats itself.
Reset

Note: When timer is used in conjunction
with a general-purpose processor, it is
assigned it to an interrupt.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
9
 It is better to assign timer functionality to a special-
purpose processor rather than software
implementation, Why?!!
Because the timer functionality occupies much of
the program’s run time, leaving little time for
other computations.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Counter
10
 Works like timer .
 Count pulses rather clock cycles .
 Example: count cars
passing over a sensor
Timer/counter
Clk
2x1 mux
16-bit up
counter
Cnt_in
16 Cnt
Top
Reset
Mode
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Applications
11
 Reaction timer
reaction
button
indicator
light
LCD
 Cascaded counters are
used to implement realtime clocks.
time: 100 ms
16/32-bit timer
 Time between turning light on
and user pushing button ?!
Clk
16-bit up
counter
16 Cnt1
 16-bit timer, clk period = 83.33 ns,
counter increments every 6 cycles.



Resolution = 6*83.33=0.5
microsec.
Range = 65535*0.5 microseconds
= 32.77 milliseconds
Want program to count millisec.,
so counter will be 65535 –
1000/0.5 = 63535
Top1
16-bit up
counter
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
16
Cnt2
Top2
Watchdog timer
12
 Inverse functionality of a regular timer.
Regular
Timer
Generate a signal for us every X time units
Watchdog
Timer
Generate a signal for the timer every X time units
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
13
Watchdog
Timer
 Often connect this signal to the reset or interrupt .
 a mechanism of ensuring that our software is
working properly .
 Failure indicating signal can be used to restart or test
parts of the system.
 Example: ATM machines .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
UART
14
 Universal Asynchronous Receiver/Transmitter
1|0|1|1|0|1
1|0|1|1|0|1
Transmitter
Receiver
1 0 0 1 0 1 0 0 0 0 1 1 0 1 1
 Send and receive serially but store in parallel.
 Used through long distances, or when have few available I/O pins.

To reduce the expense of long communication links carrying several bits in parallel, data bits
are sent sequentially.
 Start-bit, stop-bit, parity-bit.
 baud rate indicates how fast data is moving (max no. of symbols
transferred per second). So what is “Bit-rate” ?!
 Common rates include 2400, 4800, 9600, and 19.2k.
Baudrate = (2s mod / 32) *oscfreq / (12 *(256 - TH1)))
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
15
 Communication may be “full duplex” or “half duplex” .
 UARTs are commonly used with RS-232 for embedded
systems communications. It is useful to communicate
between microcontrollers and also with PCs.
 The stop bit(1-2 bit) is the data-line's idle state, and
provides a delay before the next character can start.
(asynchronous start-stop transmission).
 Parity (odd or even)

Odd parity is more reliable because it assures that there will always
be at least one data transition .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
UART Components
16
 A UART mainly contains the following components:
 Clock generator.
 Input and output shift registers
 Transmit/receive control
 Read/write control logic
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Special Receiver Conditions
17
 Overrun Error
 Occurs when the UART cannot process the byte that
just came in before the next one arrives.

Various UART devices have differing amounts of buffer space to
hold received characters. The CPU must service the UART in order
to remove characters from the buffer. If the CPU does not service
the UART and the buffer becomes full, Overrun Error will occur.
 Framing Error
 Occurs when the designated "start" and "stop" bits
are not valid.

As the "start" bit is used to identify the beginning of an incoming
character, it acts as a reference for the remaining bits. If the data
line is not in the expected idle state when the "stop" bit is
expected, a Framing Error will occur.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
18
 Parity Error
 Occurs when the number of "active" bits does not
agree with the specified parity configuration of the
UART
 Break Condition
 Occurs when the receiver input is in at the "break"
level for longer than some duration of time. This is not
necessarily an error, but appears to the receiver as a zero byte
with a framing error.
 long "break" signal can be a useful way to get the attention of a
mismatched receiver to do something (such as resetting itself
to some predefined Baud).
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
USART, DUART
19
 USART : “Universal Synchronous Asynchronous
Receiver Transmitter”




Uses a clock and data line .
No separate clock signal as in Asynchronous transmission .
No start/stop bits .
An asynchronous transmission sends nothing over the
interconnection when the transmitting device has nothing to send;
but a synchronous interface must send "pad" characters to
maintain synchronism between the receiver and transmitter .
 DUART : “Dual UART ”


combines two UARTs into a single chip .
Ex: UART & USART .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Pulse Width Modulator
20
 PWM generates an output signal that repeatedly
switches between high and low.
 Duty cycle : the percentage of time the signal is high
compared to the signal’s period .
 PWM resolution : the maximum number of pulses that you
can pack into a PWM period .
 PWM period : an arbitrarily time period in which PWM takes
place. It is chosen to give best results for your particular use .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
21
pwm_o
clk
25% duty cycle – average pwm_o is 1.25V
pwm_o
clk
50% duty cycle – average pwm_o is 2.5V.
pwm_o
clk
75% duty cycle – average pwm_o is 3.75V.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
PWM applications
22

Control the average current or voltage input to a device .

Ex: when you have a system powered by a 5 Volt power supply, so
if you filter a signal that has a 50% duty cycle you get an average
voltage of 2.5 Volts.
LPF charges while the PWM signal is “ON” and discharges while
the PWM signal is “OFF” generating an analog output.
 PWM works as DAC in cases there in no high resolution, speed,
and cost (simple and cost-effective approach) .

"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
23

Dimmer lights
To control the brightness of
the LED you have to control
the amount of current going
through the device.
 Quickly turn the LED on and
off cause Blinking, that is
undesired .
 Rather than changing the
number of times the output
goes on and off, we change
how long the output stays on
and off.
 The total current that flows
through the LED is low.
 Assume active low then,


Output is “0” most of the
time and the LED will be
“ON” most of the time.

Output is Vcc most of the
time which turns off the
LED.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
24

DC motor controlling:
DC motor can be controlled by a variable resistor, this generate
heat and hence waste power .
 This problem is eliminated by PWM .
 Speed Is controlled by changing the pulses width .
 The longer the pulses, the faster the motor turns .
 Cost effective


Encoding control commands in a single signal for use by
another device:

Controlling RF car .
 For example a (1 ms) width corresponds to a turn left command,
a (4 ms) width to turn right, and (8 ms) to forward .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
LCD controller
25



low-cost .
low-power device .
capable of displaying text and images .
 LCD types:


7-segment LCD.
dot-matrix LCD.
microcontroller
 LCD (Liquid Crystal Display)
E
R/W
RS
communications
bus
DB7–DB0
8
LCD
controller
 LCDs are extremely common in embedded systems.
 LCD Controller is a simple interface between a processor and LCD.
 This interface is parallel bus, allowing simple and fast read/write.
E (Enable): clock is used to initiate the data transfer within LCD.
R/S (Set/Reset): to select whether the data is being transferred
between the processor and the LCD.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
LCD controller instructions
26
 The different instructions available for use LCD
controller are shown in the table below.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
The bit descriptions for the different command
not used/Ignored
*
This bit can be either “1” or “0”.
Set cursor move direction
ID
27
Increment
the cursor after each byte written
S
shift Display when byte written to Display.
D
Turn Display on(1)/off(0).
C
Turn cursor on(1)/off(0).
B
cursor blink on(1)/off(0)
SC
display shift on(1)/off(0).
RL
Direction of shift Right(1)/Left(0).
DL
set Data Interface Length 8(1)/(4)
N
Number of display lines 1(0)/2(1)
F
character font 5x10 (1)/ 5x7 (0)
Poll the “BUSY Flag”
BF
this bit is set while the LCD is processing.
Move Cursor to CGRAM/Display
A
Address
Read/Write ASCII to the Display
D
Data
Enable Display/cursor
Move cursor /shift display
Set Interface Length
"Embedded Systems Design/Standard singlepurpose processors: Peripherals"
Keypad controller
28
 A Keypad consist of a set of buttons that may be pressed to provide input
to an embedded system.
 A simple keypad has buttons arranged in an N-column by M-row.
 When we press a button, one column output and one row output go high.
 To read such a keypad from software, we must scan the column and row
outputs.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
29
 The scanning may instead be performed by a
Keypad controller.
 When the controller detects a button press, it
stores a code corresponding to that button into a
register and sets an output high, indicating that
button has been pressed.
 Software may poll the output every 100 ms & read
the register when the output is high .
 Instead of using polling the output can generate an
interrupt to the general-purpose processor.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Stepper motor controller
30
 A stepper motor is an electric motor rotates a fixed number of






degrees whenever we apply a “step” signal.
In contrast, a regular electric motor rotates continuously whenever
power is applied, coasting to a stop when power is removed.
Stepper motors obviously abound in embedded systems with moving
parts, such as disk drivers, printers, photocopy and fax machines.
A stepper motor has four coils. To rotate the motor one step, we pass
current through one or two of the coils.
Stepper motor comes with four inputs corresponding to the four
coils.
Rotation achieved by applying specific voltage sequence to coils
Controller greatly simplifies this.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
31
 Single step  70˚
 Number of steps  140˚
move .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Stepper motor controller
32
Red
A
White
A’
Yellow
Black
stepper motor
B
B’
Vd
1
16
Vm
A’
2
15
B
A
3
14
B’
4
13
5
12
6
11
Phase A’
Clk
7
10
CW’/CCW
O|C
8
9
Full’/Half Step
MC3479P
GND
GND
Bias’/Set
stepper motor controller
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
33
MC3479P
Stepper Motor
Driver
10
7
8051
CW’/CCW
CLK
P1.0
P1.1
2 A’ B 15
3 A B’ 14
8051
P2.4
GND/ +V
P2.3
P2.2
P2.1
P2.0
Stepper
Motor
Stepper
Motor
stepper motor with controller
without controller
 The output pins on the stepper motor controller don’t provide enough current to
drive the stepper motor. To amplify the current a buffer is needed.
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Analog-Digital converters
34
 An analog-to-digital converter converts an analog signal to a digital
signal, and a digital-to-analog converter does the opposite.
 Such conversion are necessary because, while embedded systems deal
with digital values, an embedded system’s surroundings typically
involve many analog signals.
 We can compute the digital values from the analog, and vice-versa,
using the following ratio:
e/Vmax = d/(2n-1)
Vmax
the max. voltage that the analog signal can assume
n
the number of bits available for digital encoding
d
the present digital encoding
e
the present analog voltage
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont…
5.0V
4.5V
4.0V
3.5V
3.0V
2.5V
2.0V
1.5V
1.0V
0.5V
0V
1111
1110
1101
1100
1011
1010
1001
1000
0111
0110
0101
0100
0011
0010
0001
0000
proportionality
4
4
3
3
analog output (V)
Vmax = 7.5V
7.0V
6.5V
6.0V
5.5V
analog input (V)
35
2
1
t1
0100
t2
t3
time
t4
1000 0110 0101
Digital output
analog to digital
2
1
t1
t2
0100
t3
1000 0110
Digital input
digital to analog
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
t4
time
0101
DAC using successive approximation
36

Given an analog input signal whose voltage should range from 0 to 15 volts, and an 8-bit digital encoding,
calculate the correct encoding for 5 volts. Then trace the successive-approximation approach to find the
correct encoding.
5/15 = d/(256-1) => d=85.
½(Vmax – Vmin) = 7.5 volts
Vmax = 7.5 volts.
0
0
0
0
0
0
0
0
½(7.5 + 0) = 3.75 volts
Vmin = 3.75 volts.
0
1
0
0
0
0
0
0
½(7.5 + 3.75) = 5.63 volts
Vmax = 5.63 volts
0
1
0
0
0
0
0
0
0
1
0
1
0
0
0
0
½(5.63 + 3.75) = 4.69 volts
Vmin = 4.69 volts.
½(5.63 + 4.69) = 5.16 volts
Vmax = 5.16 volts.
0
1
0
1
0
0
0
0
½(5.16 + 4.69) = 4.93 volts
Vmin = 4.93 volts.
0
1
0
1
0
1
0
0
½(5.16 + 4.93) = 5.05 volts
Vmax = 5.05 volts.
0
1
0
1
0
1
0
0
0
1
0
1
0
1
0
1
½(5.05 + 4.93) = 4.99 volts
Successive-approximation method
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Real-time clocks
37
 A real time clock (RTC) keeps the time and date in an embedded system.
 Real-time clocks are typically composed of :



Crystal-controlled oscillator .
Numerous cascaded counters .
Battery backup.
 RTCs are present in almost any electronic device needs to keep accurate
time.
 The crystal-controlled oscillator generates a very consistent highfrequency digital pulses that feed the cascaded counters.
- the first counter counts these pulses up to the oscillator freq.,
which corresponds to exactly one second.
- at this point, it generate a pulse that feeds the next counter.
 The rechargeable back-up battery is used to keep the RTC running while
system is powered off.
 Communication between the microcontroller and a RTC is accomplished
through a serial bus .
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
References
38
"Embedded Systems Design/Standard single-purpose processors: Peripherals"