UBC104 Embedded Systems Review: Interrupts & Timers.

Slides:



Advertisements
Présentations similaires
I can tell time in French!
Advertisements

Le 4-7 novembre. Qui est présent? Quelle heure est-il? La feuille pour étudier L’examen La Jéopardie!
On conjugue! [Avoir et Etre] It is very important to learn and practise using the conjugations of verbs in French.
WALT: how to tell the time in French WILF: to be able to understand ¼ past, ½ past, ¼ to and o’clock (level 2) to be able to understand all times in French.
PERFORMANCE One important issue in networking is the performance of the network—how good is it? We discuss quality of service, an overall measurement.
SKIROC status LAL – EUDET France – 05/04/2007. Common DAQ Slice FE FPGA PHY VFE ASIC Dat a Clock+Config+Control VFE ASIC VFE ASIC VFE ASIC Conf/ Clock.
1 Case Study 1: UNIX and LINUX Chapter History of unix 10.2 Overview of unix 10.3 Processes in unix 10.4 Memory management in unix 10.5 Input/output.
An Introduction To Two – Port Networks The University of Tennessee Electrical and Computer Engineering Knoxville, TN wlg.
Traffic Sign Recognition Jacob Carlson Sean St. Onge Advisor: Dr. Thomas L. Stewart.
Electronic Instrumentation Lecturer Touseef Yaqoob1 Sensors and Instrumentation Sensors and Instrumentation.
 Components have ratings  Ratings can be Voltage, Current or Power (Volts, Amps or Watts  If a Current of Power rating is exceeded the component overheats.
A POWER POINT DEMONSTRATION. The End. Just kidding! This is serious stuff.
IP Multicast Text available on
Multisim Tutorial An Introduction to the Interface.
TP4
The Basis of the Servqual Model The Gaps The Key Service Dimensions Causes & Solutions to Gaps.
Speaking Exam Preparation
Reviewing how to conjugate ER verbs in the present tense
TP3
L’heure (Time) Quelle heure est-il? Il est une heure (it’s 1:00)
Qu’est-ce qu’ils aiment faire?
IDL_IDL bridge The IDL_IDLBridge object class allows an IDL session to create and control other IDL sessions, each of which runs as a separate process.
1 S Transmission Methods in Telecommunication Systems (4 cr) Transmission Channels.
Chapter 6- the verb ‘to go’ question words places time
Reflective verbs or Pronominal verbs
Quantum Computer A New Era of Future Computing Ahmed WAFDI ??????
Les questions et les mots interrogatifs
Unité 1 Leçon 3c Updated 10/18/12.
Improving Your Written Work
Les Fruits :.
A level French 8th December 2017.
INVERTER LOAD SPEED CONTROLLER Power demand Speed reference ENGINE 230/400V 50Hz/60Hz PMGPMG 1 f = Hz Speed =var Island Operation of the Adjustable.
© 2004 Prentice-Hall, Inc.Chap 4-1 Basic Business Statistics (9 th Edition) Chapter 4 Basic Probability.
Phase-Locked Loop Design S emiconducto r S imulation L aboratory Phase-locked loops: Building blocks in receivers and other communication electronics Main.
1. Financial (Accounting) Statements  Financial or Accounting statements are used for reporting corporate activity. 2 For Stakeholders.
in French and in English
G. Peter Zhang Neurocomputing 50 (2003) 159–175 link Time series forecasting using a hybrid ARIMA and neural network model Presented by Trent Goughnour.
Lect12EEE 2021 Differential Equation Solutions of Transient Circuits Dr. Holbert March 3, 2008.
High-Availability Linux Services And Newtork Administration Bourbita Mahdi 2016.
Technologies SoPC (System On Programmable Chip)
Quelle est la date aujourd’hui?
Qu’est-ce que tu as dans ta trousse?
Quelle est la date aujourd’hui?
Definition Division of labour (or specialisation) takes place when a worker specialises in producing a good or a part of a good.
C’est quel numéro? Count the numbers with pupils.
Roots of a Polynomial: Root of a polynomial is the value of the independent variable at which the polynomial intersects the horizontal axis (the function.
Quelle est la date aujourd’hui?
Quelle est la date aujourd’hui?
Standards Certification Education & Training Publishing Conferences & Exhibits Automation Connections ISA EXPO 2006 Wed, 1:00 Oct 18.
1-1 Introduction to ArcGIS Introductions Who are you? Any GIS background? What do you want to get out of the class?
CAN: Controller Area Network CAN Controller Area Network.
Question formation In English, you can change a statement into a question by adding a helping verb (auxiliary): does he sing? do we sing? did they sing.
WRITING A PROS AND CONS ESSAY. Instructions 1. Begin your essay by introducing your topic Explaining that you are exploring the advantages and disadvantages.
What’s the weather like?
POWERPOINT PRESENTATION FOR INTRODUCTION TO THE USE OF SPSS SOFTWARE FOR STATISTICAL ANALISYS BY AMINOU Faozyath UIL/PG2018/1866 JANUARY 2019.
By : HOUSNA hebbaz Computer NetWork. Plane What is Computer Network? Type of Network Protocols Topology.
Paul Eluard Dans Paris.
4C Telling Exact Time.
1 Sensitivity Analysis Introduction to Sensitivity Analysis Introduction to Sensitivity Analysis Graphical Sensitivity Analysis Graphical Sensitivity Analysis.
Si clauses in French.
Le Passé Composé (Perfect Tense)
Lequel The Last Part.
Chapter 6- the verb ‘to go’ question words places time
University : Ammar Telidji Laghouat Faculty : Technology Department : Electronics 3rd year Telecommunications Professor : S.Benghouini Student: Tadj Souad.
Prepositions of location and disjunctive pronous
Réflexifs.
IMPROVING PF’s M&E APPROACH AND LEARNING STRATEGY Sylvain N’CHO M&E Manager IPA-Cote d’Ivoire.
M’SILA University Information Communication Sciences and technology
Transcription de la présentation:

UBC104 Embedded Systems Review: Interrupts & Timers

UBC 104 Embedded Systems 2 Block Diagram

UBC 104 Embedded Systems 3 Interrupts Definition of ‘Interrupt’ Event that disrupts the normal execution of a program and causes the execution of special instructions

UBC 104 Embedded Systems 4 Interrupt Handling Code that deals with interrupts: Interrupt Handler or Interrupt Service Routines (ISRs) Possible code: void ISR(void) interrupt 1 { ++interruptcnt; } Interrupt number

UBC 104 Embedded Systems 5 Interrupt Overheads Interrupt arrives Complete current instruction Save essential register information Vector to ISR Save additional register information Execute body of ISR Restore other register information Return from interrupt and restore essential registers Resume task Interrupt Latency Interrupt Termination

UBC 104 Embedded Systems 6 SFR Map – Timer

UBC 104 Embedded Systems 7 Timer Code void TimerInit(void) { T2CON=0x04;// Load Timer 2 control register TH2=0xFC; // Load Timer 2 high byte RCAP2H=0xFC;// Load Timer 2 reload capt. reg. high byte TL2=0x18;// Load Timer 2 low byte RCAP2L=0x18;// Load Timer 2 reload capt. reg. low byte ET2 = 1; // Enable interrupt TR2 = 1;// Start Timer 2 running } void handleTimer2 (void) interrupt 5 { /* execute interrupt code */ } Initialization Start of Timer Interrupt Service Routine

UBC 104 Embedded Systems 8 Calculation of Register Settings Oscillator = 24 MHz Timer clock= (24 / 12) MHz = 2 MHz Timer cycle = = 500ns Delay count = delay time / cycle time 1 ms / 500 ns = 2000 Base number= = = 6192 = 0x MHz 1

UBC 104 Embedded Systems 9 Summary: Interrupts & Timers Interrupts: Event that disrupts the normal execution of a program and causes the execution of special instructions Interrupt Latency: Time from event to execution of service routine Interrupt Response Time: Interrupt latency + Time for service routine Interrupt Termination: Time taken after interrupt service routine Timer: Counter that causes interrupt at overflow

UBC104 Embedded Systems RS232 Communication

UBC 104 Embedded Systems 11 Overview Basics of serial communications RS232 details 8051-support for serial communication

UBC 104 Embedded Systems 12 SFR Map – UART Registers

UBC 104 Embedded Systems 13 UART Registers

UBC 104 Embedded Systems 14 Serial Interface Basics Also called Universal Asynchronus Receiver/ Transmitter (UART) or after the I standards:  RS232 (-C) or EIA232

UBC 104 Embedded Systems 15 Serial Interface Basics also called Universal Asynchronus Receiver/ Transmitter (UART) or the relevant standards:  RS232 (-C) or EIA232 2 Receive Data 3 Transmit Data 5 Signal Ground

UBC 104 Embedded Systems 16 Typical 3-wire Interface

UBC 104 Embedded Systems 17 uController Pin-Out

UBC 104 Embedded Systems 18 RS232 Signals Signals between +25V and -25V; some say ±15V usually +12V to -12V

UBC 104 Embedded Systems 19 RS232 Signals Signals between +25V and -25V; some say ±15V usually +12V to -12V Logic ‘1’ Logic ‘0’

UBC 104 Embedded Systems 20 RS232 Signals Signals between +25V and -25V; some say ±15V usually +12V to -12V

UBC 104 Embedded Systems 21 RS232 Signals Signals between +25V and -25V; some say ±15V usually +12V to -12V 8051 runs on 3V or 5V

UBC 104 Embedded Systems 22 RS232 Signals Signals between +25V and -25V; some say ±15V usually +12V to -12V 8051 runs on 3V or 5V Driver chip translates between voltages

UBC 104 Embedded Systems 23 Valid Signals

UBC 104 Embedded Systems 24 Valid Signals Figure courtesy of

UBC 104 Embedded Systems 25 MCBx51 Board TX0 RX0 2 3

UBC 104 Embedded Systems 26 Basic 3-Wire Connection of Machines TXD GND RXD

UBC 104 Embedded Systems 27 Basic 3-Wire Connection of Machines What goes over these wires? TXD GND RXD

UBC 104 Embedded Systems 28 RS-232 Frame Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit)

UBC 104 Embedded Systems 29 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit)

UBC 104 Embedded Systems 30 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 31 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop 1 1 Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 32 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 33 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 34 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 35 RS-232 Frame StartD0D1D2D3D4D5D6D7Stop Every RS-232 consists of:  1 start bit  8 data bits  1 stop bit  (optional 1 parity bit) ‘a’= 0x61 =

UBC 104 Embedded Systems 36 Signal Timing StartD0D1D2D3D4D5D6D7Stop ?

UBC 104 Embedded Systems 37 Signal Timing (continued) StartD0D1D2D3D4D5D6D7Stop ? bit period

UBC 104 Embedded Systems 38 Baud Rate Baud specifies the inverse of the bit-period e.g Baud = a bit-period of 1/9600 second = microseconds Typicall data rates: 75, 110, 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 33600, 56000, and (rarely) baud.

UBC 104 Embedded Systems 39 Serial I/O with bare hands #define BIT_PERIOD 1042 sendByte(unsigned char content) { unsigned char mask; mask= 1; P3.1= 0; // Start bit wait (BIT_PERIOD); for (i= 0; i<8; i++) {// Send content P3.1= (content&mask) ? 1 : 0; wait (BIT_PERIOD); mask<= 1; } P3.1= 0;// Stop bit wait (BIT_PERIOD); P3.1= 1; }

UBC 104 Embedded Systems 40 Serial I/O with bare hands #define BIT_PERIOD 1042 sendByte(unsigned char content) { unsigned char mask; mask= 1; P3.1= 0; // Start bit wait (BIT_PERIOD); for (i= 0; i<8; i++) {// Send content P3.1= (content&mask) ? 1 : 0; wait (BIT_PERIOD); mask<= 1; } P3.1= 0;// Stop bit wait (BIT_PERIOD); P3.1= 1; }

UBC 104 Embedded Systems 41 Serial I/O with bare hands #define BIT_PERIOD 1042 sendByte(unsigned char content) { unsigned char mask; mask= 1; P3.1= 0; // Start bit wait (BIT_PERIOD); for (i= 0; i<8; i++) {// Send content P3.1= (content&mask) ? 1 : 0; wait (BIT_PERIOD); mask<= 1; } P3.1= 0;// Stop bit wait (BIT_PERIOD); P3.1= 1; } You do not need to do this!!!

UBC 104 Embedded Systems 42 UART modes Mode 0: 8 data bits (LSB first) are transmitted/received at a fixed baud rate of 1/12 of the oscillator frequency. (synchronus mode)

UBC 104 Embedded Systems 43 UART modes Mode 0: 8 data bits (LSB first) are transmitted/received at a fixed baud rate of 1/12 of the oscillator frequency. (synchronus mode) Mode 1: 10 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8 data bits (LSB first), and a stop bit (1) at a variable baud rate.

UBC 104 Embedded Systems 44 UART modes Mode 0: 8 data bits (LSB first) are transmitted/received at a fixed baud rate of 1/12 of the oscillator frequency. (synchronus mode) Mode 1: 10 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8 data bits (LSB first), and a stop bit (1) at a variable baud rate. Mode 2: 11 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1). On transmit, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or 1 (for example, the parity bit (P, in the PSW) could be moved into TB8). On receive, the 9th data bit goes into RB8 in Special Function register SCON. The baud rate is programmable to either 1/32 or 1/64 the oscillator frequency. Mode 3: Mode 3 is the same as Mode 2 in all respects except the baud rate is variable.

UBC 104 Embedded Systems 45 UART modes Mode 0: 8 data bits (LSB first) are transmitted/received at a fixed baud rate of 1/12 of the oscillator frequency. (synchronus mode) Mode 1: 10 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8 data bits (LSB first), and a stop bit (1) at a variable baud rate. Mode 2: 11 bits are transmitted (through TXD) or received (through RXD): a start bit (0), 8 data bits (LSB first), a programmable 9th data bit, and a stop bit (1). On transmit, the 9th data bit (TB8 in SCON) can be assigned the value of 0 or 1 (for example, the parity bit (P, in the PSW) could be moved into TB8). On receive, the 9th data bit goes into RB8 in Special Function register SCON. The baud rate is programmable to either 1/32 or 1/64 the oscillator frequency. Mode 3: Mode 3 is the same as Mode 2 in all respects except the baud rate is variable. Mode 0 Baud Rate = 12 Oscillator Frequency Mode 2 Baud Rate = 2 SMOD1 x 64 Oscillator Frequency Mode 1/3 Baud Rate = 2 SMOD1 x 32 Timer Overflow Rate

UBC 104 Embedded Systems 46 SMOD1 SMOD1: Double Baud rate SMOD0: Enables framing error detection

UBC 104 Embedded Systems 47 Framing Error Detection

UBC 104 Embedded Systems 48 Timer 1 Mode 1/3 Baud Rate = 2 SMOD1 x 32 Timer Overflow Rate Mode 1/3 Baud Rate = 12 x [256 – TH1] Oscillator Frequency 2 SMOD1 x 32 Baud Rate [256 – TH1] = Oscillator Frequency 2 SMOD1 x 3212 x Baud Rate TH1 = 256 – Oscillator Frequency 2 SMOD1 x 3212 x

UBC 104 Embedded Systems 49 Timer 1 Commonly Used BAUD Rates

UBC 104 Embedded Systems 50 SCON Documentation

UBC 104 Embedded Systems 51 SCON & SBUF SCON controls the functionality of the UART device:  SM0&SM1= Determine the mode  SM2= Multiprocessor Flag  REN= Receive Enable Flag  TB8/RB8= Transmit/Receive Parity Flag  TI/RI = Transmit/Receive Interrupt Flag SBUF is the transmit&receive buffer

UBC 104 Embedded Systems 52 SBUF SBUF is actually two separate registers: a transmit buffer and a receive buffer register:  When data is moved to SBUF, it goes to the transmit buffer where it is held for serial transmission; moving a byte to SBUF initiates the transmission.  When data is moved from SBUF, it comes from the receive buffer.

UBC 104 Embedded Systems 53 SBUF and TI/RI 8 data SBUF 8 TI Stop bit Start bit Send 8-bit data Transmitter Buffer is empty 10 bit parallel to serial conversion Serial data transmit TRANSMITTER HALF 8 data bits start bit stop bit Tx bit 8 data SBUF 8 RI Start bit Stop bit Receive 8-bit data Receive data is available 10 bit serial to parallel conversion Serial data receive RECEIVER HALF 8 data bits stopstart Rx

UBC 104 Embedded Systems 54 SBUF and Parity Bit in TB8/RB8

UBC 104 Embedded Systems 55 Timer 1 Example 1.Set T1 for Mode 2 2.Load TH1 with the initial value 3.Set SCON for Mode 1 4.Start Timer1 5.Clear TI 6.Load SBUF with the byte to be transferred 7.Wait until TI becomes 1 8.Go back to Step5 for next byte TCON= 0x20; TH1= 0xF5; SCON|= 0x50; TR1= 1; TI= 0; do { SBUF= byte[i]; while (!TI); } while(more_bytes);

UBC 104 Embedded Systems 56 Timer 1 Example (continued) 1.Set T1 for Mode 2 2.Load TH1 with the initial value 3.Set SCON for Mode 1 4.Start Timer1 5.Clear RI 6.Wait for byte to be received 7.Copy received byte out of SBUF 8.Return received byte TCON= 0x20; TH1= 0xF5; SCON|= 0x50; TR1= 1; RI= 0; while (!RI); result= SBUF; return SBUF;

UBC 104 Embedded Systems 57 Possible Configurations

UBC 104 Embedded Systems 58 T2CON Documentation

UBC 104 Embedded Systems 59 Timer 2 Commonly Used BAUD Rates

UBC 104 Embedded Systems 60 Timer 2 Calculation Mode 1/3 Baud Rate = 32 x [65536 – (RCAP2H, RCAP2L)] Oscillator Frequency Baud Rate (RCAP2H,RCAP2L) = – Oscillator Frequency 32 x

UBC 104 Embedded Systems 61 Timer2 Example 1.Set T1 for Mode 2 2.Load RCAP high/low with the initial value 3.Set SCON for Mode 1 4.Start Timer1 5.Clear TI 6.Load SBUF with the byte to be transferred 7.Wait until TI becomes 1 8.Go back to Step5 for next byte T2CON|= 0x30; RCAP2H = 0xFF; RCAP2L = 0xB2; SCON|= 0x50; TR2= 1; TI= 0; do { SBUF= byte[i]; while (!TI); } while(more_bytes);

UBC 104 Embedded Systems 62 Internal Baud-Rate Generator

UBC 104 Embedded Systems 63 BDRCON

UBC 104 Embedded Systems 64 Using BRL to Transmit 1.Set T1 for Mode 2 2.Load TH1 with the initial value 3.Set SCON for Mode 1 4.Start Timer1 5.Clear TI 6.Load SBUF with the byte to be transferred 7.Wait until TI becomes 1 8.Go back to Step5 for next byte BDRCON= 0x0E; BRL= 0xF5; SCON|= 0x50; BDRCON|= 0x10; TI= 0; do { SBUF= byte[i]; while (!TI); } while(more_bytes);