Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.

Slides:



Advertisements
Similar presentations
INPUT-OUTPUT ORGANIZATION
Advertisements

CPE 201 Digital Design Lecture 25: Register Transfer Level Design (2)
RADIO FREQUENCY BASED SERIAL COMMUNICATION..
4-1 Timers Timers can be used for  timing  event counting  pulse width measurement  pulse generation  frequency multiplication There are 8 Timers.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 3: Standard Single Purpose Processors - Peripherals.
In this presentation you will:
Lecture 9: D/A and A/D Converters
EET260: A/D and D/A converters
Counter Circuits and VHDL State Machines
Read Chapter 3 (David E. Simon, An Embedded Software Primer)
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals.
Standard Single Purpose Processors: Peripherals. This Week In DIG II  Timers and counters  Watchdog timers  UART (Universal asynchronous receiver /
7-1 Digital Serial Input/Output Two basic approaches  Synchronous shared common clock signal all devices synchronised with the shared clock signal data.
Timers and Interrupts Shivendu Bhushan Summer Camp ‘13.
Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals ECE 4330 Embedded System.
Digital I/O Connecting to the Outside World
CS244-Introduction to Embedded Systems and Ubiquitous Computing Instructor: Eli Bozorgzadeh Computer Science Department UC Irvine Winter 2012.
Engineering 1040: Mechanisms & Electric Circuits Fall 2011 Introduction to Embedded Systems.
INPUT-OUTPUT ORGANIZATION
16-Bit Timer/Counter 1 and 3 Counter/Timer 1,3 (TCNT1, TCNT3) are identical in function. Three separate comparison registers exist. Thus, three separate.
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
Chapter 4 Standard Single Purpose Processors: Peripherals
Input/Output mechanisms
7/23 Timers in Coldfire Processor Computer Science & Engineering Department Arizona State University Tempe, AZ Dr. Yann-Hang Lee (480)
Chapter 13 Linear-Digital ICs. Copyright ©2009 by Pearson Education, Inc. Upper Saddle River, New Jersey All rights reserved. Electronic Devices.
PIT: Programmable Interval Timer
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
©2008 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected under all copyright laws as they currently exist.
Unit 10.2 Timer Examples. Example – Music Generation Channel 6 – Set up as a timer Output to Generate Square Waves Channel 4 – Set up as a timer Output.
MICROPROCESSOR INPUT/OUTPUT
AT91 Embedded Peripherals
MCU: Interrupts and Timers Ganesh Pitchiah. What’s an MCU ?
Lecture 20: Communications Lecturers: Professor John Devlin Mr Robert Ross.
PIT Programming Examples Working with the modes of PIT.
1 Lab 5: Controls and feedback. 2 Lab 5: Control and Feedback This embedded system uses the Photo sensor to detect the light intensity of the environment.
Other Chapters From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Advanced Microprocessor1 I/O Interface Programmable Interval Timer: 8254 Three independent 16-bit programmable counters (timers). Each capable in counting.
Timer Timer is a device, which counts the input at regular interval (δT) using clock pulses at its input. The counts increment on each pulse and store.
CCP MODULES  The CCP module (Capture/Compare/PWM) is a peripheral which allows the user to time and control different events.  Capture Mode provides.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Module Introduction Purpose  This training module provides an overview of the analog interfaces.
1 Transmission of Digital Data : Interface and Modems.
© 2009, Renesas Technology America, Inc., All Rights Reserved 1 Course Introduction  Purpose:  This course provides an overview of the serial communication.
Embedded Systems Design 1 Lecture Set C Interfacing the MCS-51 to: –D/A Converter –A/D Converter.
1 4-Integrating Peripherals in Embedded Systems (cont.)
1 4-Integrating Peripherals in Embedded Systems (cont.)
CE-2810 Dr. Mark L. Hornick 1 Serial Communications Sending and receiving data between devices.
Closed Loop Temperature Control Circuit with LCD Display Mike Wooldridge ECE 4330 Embedded Systems.
Networked Embedded Systems Pengyu Zhang & Sachin Katti EE107 Spring 2016 Lecture 4 Timers and Interrupts.
1 4-Integrating Peripherals in Embedded Systems (cont.)
1. PIC ADC  PIC18F877 has 8 analog input channels i.e. port A pins(RA0 to RA5) and port E pins(RE1 and RE2). These pins are used as Analog input pins.
1 4-Integrating Peripherals in Embedded Systems. 2 Introduction Single-purpose processors  Performs specific computation task  Custom single-purpose.
Electronic Devices and Circuit Theory
Case Study #1 Microcontroller System. What is a microcontroller? A microcontroller can be considered a self-contained system with a processor, memory.
Application Case Study Christmas Lights Controller
Introduction to Microcontroller Technology
Application Case Study Security Camera Controller
Timers and Event Counters
Networked Embedded Systems Sachin Katti
Timer and Interrupts.
Chapter 13 Linear-Digital ICs
4-Integrating Peripherals in Embedded Systems
4-Integrating Peripherals in Embedded Systems
Pulse Width Modulation (PWM) Motor Feedback - Shaft Encoder
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
Introduction to Microprocessors and Microcontrollers
Chapter 4 Standard Single Purpose Processors: Peripherals
Chapter 4 Standard Single Purpose Processors: Peripherals
Wireless Embedded Systems
Chapter 4 Standard Single Purpose Processors: Peripherals
Chapter 4 Standard Single Purpose Processors: Peripherals
Presentation transcript:

Embedded Systems Design: A Unified Hardware/Software Introduction 1 Chapter 4 Standard Single Purpose Processors: Peripherals

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 2 Introduction Single-purpose processors –Performs specific computation task –Custom single-purpose processors Designed by us for a unique task –Standard single-purpose processors “Off-the-shelf” -- pre-designed for a common task a.k.a., peripherals serial transmission analog/digital conversions

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 3 Timers, counters, watchdog timers Timer: measures time intervals –To generate timed output events e.g., hold traffic light green for 10 s –To measure input events e.g., measure a car’s speed Based on counting clock pulses E.g., let Clk period be 10 ns And we count 20,000 Clk pulses Then 200 microseconds have passed 16-bit counter would count up to 65,535*10 ns = microsec., resolution = 10 ns Top: indicates top count reached, wrap-around 16-bit up counter Clk Cnt Basic timer Top Reset 16

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 4 Counters Counter: like a timer, but counts pulses on a general input signal rather than clock –e.g., count cars passing over a sensor –Can often configure device as either a timer or counter 16-bit up counter Clk 16 Cnt_in 2x1 mux Mode Timer/counter Top Reset Cnt

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 5 Other timer structures Top2 Time with prescaler 16-bit up counter Clk Prescaler Mode Interval timer –Indicates when desired time interval has passed –We set terminal count to desired interval Number of clock cycles = Desired time interval / Clock period Cascaded counters Prescaler –Divides clock –Increases range, decreases resolution 16-bit up counter Clk 16 Terminal count = Top Reset Timer with a terminal count Cnt 16-bit up counter Clk 16-bit up counter 16 Cnt2 Top1 16/32-bit timer Cnt1 16

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 6 Example: Reaction Timer indicator light reaction button time: 100 ms LCD /* main.c */ #define MS_INIT void main(void){ int count_milliseconds = 0; configure timer mode set Cnt to MS_INIT wait a random amount of time turn on indicator light start timer while (user has not pushed reaction button){ if(Top) { stop timer set Cnt to MS_INIT start timer reset Top count_milliseconds++; } turn light off printf(“time: %i ms“, count_milliseconds); } Measure time between turning light on and user pushing button –16-bit timer, clk period is ns, counter increments every 6 cycles –Resolution = 6*83.33=0.5 microsec. –Range = 65535*0.5 microseconds = milliseconds –Want program to count millisec., so initialize counter to – 1000/0.5 = 63535

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 7 Watchdog timer scalereg checkreg timereg to system reset or interrupt oscclk prescaler overflow /* main.c */ main(){ wait until card inserted call watchdog_reset_routine while(transaction in progress){ if(button pressed){ perform corresponding action call watchdog_reset_routine } /* if watchdog_reset_routine not called every < 2 minutes, interrupt_service_routine is called */ } watchdog_reset_routine(){ /* checkreg is set so we can load value into timereg. Zero is loaded into scalereg and is loaded into timereg */ checkreg = 1 scalereg = 0 timereg = } void interrupt_service_routine(){ eject card reset screen } Must reset timer every X time unit, else timer generates a signal Common use: detect failure, self-reset Another use: timeouts –e.g., ATM machine –16-bit timer, 2 microsec. resolution –timereg value = 2*( )–X = –X –For 2 min., X = 120,000 microsec.

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 8 Serial Transmission Using UARTs embedded device Sending UART Receiving UART start bit data end bit UART: Universal Asynchronous Receiver Transmitter –Takes parallel data and transmits serially –Receives serial data and converts to parallel Parity: extra bit for simple error checking Start bit, stop bit Baud rate –signal changes per second –bit rate usually higher

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 9 Pulse width modulator clk pwm_o 25% duty cycle – average pwm_o is 1.25V clk pwm_o 50% duty cycle – average pwm_o is 2.5V. clk pwm_o 75% duty cycle – average pwm_o is 3.75V. Generates pulses with specific high/low times Duty cycle: % time high –Square wave: 50% duty cycle Common use: control average voltage to electric device –Simpler than DC-DC converter or digital-analog converter –DC motor speed, dimmer lights Another use: encode commands, receiver uses timer to decode

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 10 Controlling a DC motor with a PWM void main(void){ /* controls period */ PWMP = 0xff; /* controls duty cycle */ PWM1 = 0x7f; while(1){}; } The PWM alone cannot drive the DC motor, a possible way to implement a driver is shown below using an MJE3055T NPN transistor. Internal Structure of PWM clk_div cycle_high counter ( 0 – 254)‏ 8-bit comparator controls how fast the counter increments counter < cycle_high, pwm_o = 1 counter >= cycle_high, pwm_o = 0 pwm_o clk Relationship between applied voltage and speed of the DC Motor DC MOTOR 5V From processor

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 11 LCD controller E R/W RS DB7–DB0 LCD controller communications bus microcontroller 8 void WriteChar(char c){ RS = 1; /* indicate data being sent */ DATA_BUS = c; /* send data to LCD */ EnableLCD(45); /* toggle the LCD with appropriate delay */ }

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 12 Keypad controller

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 13 Analog-to-digital converters proportionality V max = 7.5V 0V V 1.0V 1.5V 2.0V 2.5V 3.0V 3.5V 4.0V 4.5V 5.0V 5.5V 6.0V 6.5V 7.0V analog to digital t1t2t3 t time anal og inp ut (V)‏ Digital output digital to analog t1t2t3 t4 time anal og output (V)‏ Digital input

Embedded Systems Design: A Unified Hardware/Software Introduction, (c) 2000 Vahid/Givargis 14 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/(28-1)‏ d= 85 Successive-approximation method Digital-to-analog conversion using successive approximation Encoding: ½(V max – V min ) = 7.5 volts V max = 7.5 volts. ½( ) = 3.75 volts V min = 3.75 volts ½( ) = 5.63 volts V max = 5.63 volts ½( ) = 4.69 volts V min = 4.69 volts ½( ) = 5.16 volts V max = 5.16 volts ½( ) = 4.93 volts V min = 4.93 volts ½( ) = 5.05 volts V max = 5.05 volts ½( ) = 4.99 volts