420 likes | 969 Views
Standard single-purpose processors. Done by: Muna & Rasha Supervised by: Dr. Lo’ai tawalbeh. Outline. Introduction. Processors. General- purpose. Single-purpose. Custom. Standard. Cont…. General- purpose. Many computational tasks , large variety of applications. Single-purpose.
E N D
Standard single-purpose processors Done by: Muna & Rasha Supervised by: Dr. Lo’aitawalbeh
Outline "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Introduction Processors General- purpose Single-purpose Custom Standard "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont… General- purpose Many computational tasks , large variety of applications Single-purpose 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 • Known as Peripherals . (exist on the periphery of the CPU) • “Off-the shelf” pre-designed for a common task. • Embedded system designers use standard single-processor 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 !!!! • If we are already using a general-purpose processor, then implementing a task on an additional single-purposeprocessor rather than in software may add to the system size and power consumption. "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Timer • A device that generates a signal pulse at specified time intervals . • Mainly consist of a register, counter, and an extremely simple controller. • 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 Number of clock cycles = Desired real-time value / Clock cycle "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Basic timer 16-bit up counter Cnt 16 Clk Top Reset • The register holds a count value (number of clock cycles). • Thecounteris 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. • Note: When timer is used in conjunction with a general-purpose processor, it is assigned it to an interrupt. How timer works? "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont… • 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"
Timer/counter Clk 2x1 mux 16-bit up counter Cnt 16 Top Cnt_in Reset Mode Counter • Works like timer . • Count pulses rather clock cycles . • Example: count cars passing over a sensor "Embedded Systems Design/Standard single-purpose processors: Peripherals"
16/32-bit timer 16-bit up counter Clk Cnt1 16 Top1 reaction button indicator light 16-bit up counter Cnt2 16 LCD time: 100 ms Applications • Cascaded counters are used to implement real-time clocks. • Reaction timer • Time between turning light on and user pushing button ?! • 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 Top2 "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Watchdog timer • 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… • 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 . Watchdog Timer Failure "Embedded Systems Design/Standard single-purpose processors: Peripherals"
UART • Universal Asynchronous Receiver/Transmitter • 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. Transmitter Receiver 1|0|1|1|0|1 1|0|1|1|0|1 1 0 0 1 0 1 0 0 0 0 1 1 0 1 1 Baudrate = (2s mod / 32) *oscfreq / (12 *(256 - TH1))) "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Cont… • 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 • 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 • 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… • 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 • 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 • 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"
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. Cont… "Embedded Systems Design/Standard single-purpose processors: Peripherals"
PWM applications • 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… • 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… • 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"
microcontroller E communications bus R/W RS DB7–DB0 8 LCD controller LCD controller • LCD (Liquid Crystal Display) • low-cost . • low-power device . • capable of displaying text and images . • LCD types: • 7-segment LCD. • dot-matrix LCD. • 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 • The different instructions available for use LCD controller are shown in the table below. "Embedded Systems Design/Standard single-purpose processors: Peripherals"
"Embedded Systems Design/Standard single-purpose processors: Peripherals"
Keypad controller • 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… • 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 • 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… • Single step 70˚ • Number of steps 140˚ move . "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Red A Vd 1 16 Vm White A’ A’ 2 15 B Yellow B A 3 14 B’ Black B’ 4 13 GND GND 5 12 Bias’/Set 6 11 Phase A’ Clk 7 10 CW’/CCW O|C 8 9 Full’/Half Step MC3479P Stepper motor controller stepper motor stepper motor controller "Embedded Systems Design/Standard single-purpose processors: Peripherals"
8051 MC3479P Stepper Motor Driver P2.4 P2.3 P2.2 P2.1 P2.0 GND/ +V 8051 CW’/CCW P1.0 P1.1 10 7 B 15 B’ 14 CLK Stepper Motor 2 A’ 3 A Stepper Motor Cont… 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 • 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) "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Vmax = 7.5V 4 4 1111 7.0V 1110 6.5V 1101 3 3 6.0V 1100 5.5V 1011 2 2 analog input (V) analog output (V) 5.0V 1010 4.5V 1001 1 1 4.0V 1000 3.5V 0111 time time 0110 3.0V t1 t2 t3 t4 t1 t2 t3 t4 2.5V 0101 0100 1000 0110 0101 0100 1000 0110 0101 2.0V 0100 Digital input Digital output 1.5V 0011 1.0V 0010 0.5V 0001 0V 0000 analog to digital digital to analog proportionality Cont… "Embedded Systems Design/Standard single-purpose processors: Peripherals"
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 1 0 1 0 1 0 1 DAC using successive approximation • 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. ½(5.63 + 4.69) = 5.16 volts Vmax = 5.16 volts. ½(Vmax – Vmin) = 7.5 volts Vmax = 7.5 volts. ½(7.5 + 0) = 3.75 volts Vmin = 3.75 volts. ½(5.16 + 4.69) = 4.93 volts Vmin = 4.93 volts. ½(7.5 + 3.75) = 5.63 volts Vmax = 5.63 volts ½(5.16 + 4.93) = 5.05 volts Vmax = 5.05 volts. ½(5.63 + 3.75) = 4.69 volts Vmin = 4.69 volts. ½(5.05 + 4.93) = 4.99 volts Successive-approximation method "Embedded Systems Design/Standard single-purpose processors: Peripherals"
Real-time clocks • 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 high-frequency 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 "Embedded Systems Design/Standard single-purpose processors: Peripherals"