UBI >> Contents Lecture 14 RF link using the eZ430-RF2500 & Interrupts MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior.

Slides:



Advertisements
Similar presentations
Chapter 3 Basic Input/Output
Advertisements

Chung-Ta King National Tsing Hua University
1/1/ / faculty of Electrical Engineering eindhoven university of technology Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir.
I/O Unit.
1/1/ / faculty of Electrical Engineering eindhoven university of technology Introduction Part 3: Input/output and co-processors dr.ir. A.C. Verschueren.
FIU Chapter 7: Input/Output Jerome Crooks Panyawat Chiamprasert
CSC Timers Since this is a microcontroller it mainly finds itself in embedded devices Quite often embedded devices need to synchronize events The.
Interrupts What is an interrupt? What does an interrupt do to the “flow of control” Interrupts used to overlap computation & I/O – Examples would be console.
Interrupts (contd..) Multiple I/O devices may be connected to the processor and the memory via a bus. Some or all of these devices may be capable of generating.
COMP3221: Microprocessors and Embedded Systems Lecture 15: Interrupts I Lecturer: Hui Wu Session 1, 2005.
6-1 I/O Methods I/O – Transfer of data between memory of the system and the I/O device Most devices operate asynchronously from the CPU Most methods involve.
Introduction An interrupt is an event which informs the CPU that its service (action) is needed. Sources of interrupts: internal fault (e.g.. divide by.
Basic Input/Output Operations
Midterm Tuesday October 23 Covers Chapters 3 through 6 - Buses, Clocks, Timing, Edge Triggering, Level Triggering - Cache Memory Systems - Internal Memory.
1 Interrupts INPUT/OUTPUT ORGANIZATION: Interrupts CS 147 JOKO SUTOMO.
INPUT/OUTPUT ORGANIZATION INTERRUPTS CS147 Summer 2001 Professor: Sin-Min Lee Presented by: Jing Chen.
UBI >> Contents Chapter 15 Advanced Laboratories RF link using the eZ430-RF2500 MSP430 Teaching Materials Texas Instruments Incorporated University of.
The 8051 Microcontroller and Embedded Systems
INTERRUPTS PROGRAMMING
Interrupts. 2 Definition: An electrical signal sent to the CPU (at any time) to alert it to the occurrence of some event that needs its attention Purpose:
Exception and Interrupt Handling
Introduction to Embedded Systems
COMP201 Computer Systems Exceptions and Interrupts.
Interrupts. What Are Interrupts? Interrupts alter a program’s flow of control  Behavior is similar to a procedure call »Some significant differences.
MICROPROCESSOR INPUT/OUTPUT
CHAPTER 3 TOP LEVEL VIEW OF COMPUTER FUNCTION AND INTERCONNECTION
Khaled A. Al-Utaibi  Interrupt-Driven I/O  Hardware Interrupts  Responding to Hardware Interrupts  INTR and NMI  Computing the.
PIC16F877 ISR Points to note Interrupt Triggers –Individual interrupt flag bits are set, regardless of the status of their corresponding mask bit, PEIE.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
UBI >> Contents Chapter 2 Software Development tools Code Composer Essentials v3: Code Debugging Texas Instruments Incorporated University of Beira Interior.
Computer Architecture Lecture 2 System Buses. Program Concept Hardwired systems are inflexible General purpose hardware can do different tasks, given.
8051 Micro controller. Architecture of 8051 Features of 8051.
Accessing I/O Devices Processor Memory BUS I/O Device 1 I/O Device 2.
13-Nov-15 (1) CSC Computer Organization Lecture 7: Input/Output Organization.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
ECE 447 Fall 2009 Lecture 7: MSP430 Polling and Interrupts.
CSCI1600: Embedded and Real Time Software Lecture 9: Input Output Concepts Steven Reiss, Fall 2015.
Input/Output Problems Wide variety of peripherals —Delivering different amounts of data —At different speeds —In different formats All slower than CPU.
Embedded Systems Design 1 Lecture Set 8 MCS-51 Interrupts.
CS4101 嵌入式系統概論 Interrupt 金仲達教授 國立清華大學資訊工程學系 ( Materials from MSP430 Microcontroller Basics, John H. Davies, Newnes, 2008 )
بسم الله الرحمن الرحيم MEMORY AND I/O.
Lecture 3 CSE 341 – Microprocessors Lecture 3 Md. Omar Faruqe UB 1228
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
1 Device Controller I/O units typically consist of A mechanical component: the device itself An electronic component: the device controller or adapter.
Introduction to Exceptions 1 Introduction to Exceptions ARM Advanced RISC Machines.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Lecture – 8 Interrupt 1. Outline Introduction Handling interrupt Interrupt sources Switching interrupt Peripheral interrupts Using two interrupts Conclusions.
Architectures of Digital Information Systems Part 1: Interrupts and DMA dr.ir. A.C. Verschueren Eindhoven University of Technology Section of Digital.
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Microprocessor Systems Design I
Mon. Oct 2 Announcements Quiz Postponed to Wednesday – still only on 2.a + 2.b Video lecture for 2.a posted Lab 6 experiment extension You must come to.
CS4101 嵌入式系統概論 Interrupts Prof. Chung-Ta King
Timer and Interrupts.
Chapter 6 General Purpose Input/Output
Computer Architecture
Interrupts In 8085 and 8086.
CS4101 Introduction to Embedded Systems Lab 4: Interrupt
COMPUTER PERIPHERALS AND INTERFACES
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Md. Mojahidul Islam Lecturer Dept. of Computer Science & Engineering
Interrupt handling Explain how interrupts are used to obtain processor time and how processing of interrupted jobs may later be resumed, (typical.
Embedded System Development Lecture 7 2/21/2007
An Embedded Software Primer
COMP3221: Microprocessors and Embedded Systems
Chapter 15 Advanced Laboratories RF link using the eZ430-RF2500
Presentation transcript:

UBI >> Contents Lecture 14 RF link using the eZ430-RF2500 & Interrupts MSP430 Teaching Materials Texas Instruments Incorporated University of Beira Interior (PT) Pedro Dinis Gaspar, António Espírito Santo, Bruno Ribeiro, Humberto Santos University of Beira Interior, Electromechanical Engineering Department Copyright 2009 Texas Instruments All Rights Reserved

UBI >> Contents 2 Copyright 2009 Texas Instruments All Rights Reserved Contents (1/2)  RF Introduction RF Introduction  The application The application  The hardware The hardware  The software The software  Configuration Configuration  Algorithms Algorithms  New challenges New challenges

UBI >> Contents 3 Copyright 2009 Texas Instruments All Rights Reserved Contents (2/2)  Interrupt Introduction Interrupt Introduction  Interrupt: Processor's Perspective Interrupt: Processor's Perspective  Interrupt Service Routine Interrupt Service Routine  Some Common Questions Some Common Questions  Interrupt Vector Table Interrupt Vector Table  Interrupt Latency Interrupt Latency  Sources of Interrupt Overhead Sources of Interrupt Overhead

UBI >> Contents 4 Copyright 2009 Texas Instruments All Rights Reserved RF Introduction (1/3)  This laboratory demonstrates the operation of a small wireless communication application;  The purpose of this laboratory is to send and receive text messages, making use of RF links between the central unit (base unit) and the various peripheral units (remote units).  It is an integrated application, using some peripherals of the MSP430, in particular, the USCIx communication modules;  Additionally, it uses the CC2500 radio transceiver as an interface to external devices;  Even though the application is simple, it is motivating to the user because the IO console allows easy interaction with the system;

UBI >> Contents 5 Copyright 2009 Texas Instruments All Rights Reserved  This laboratory has the following objectives:  To demonstrate the importance of software organization as a fundamental part of an embedded systems project: To approach the problem using a top-down approach, applying the necessary abstraction to organize the software into functional layers.  To give an example of the management of a complex project, integrating together more than one functional module: To develop a modular structure so that several functional modules co-exist together within a single software project. RF Introduction (2/3)

UBI >> Contents 6 Copyright 2009 Texas Instruments All Rights Reserved RF Introduction (3/3)  This laboratory has the following objectives (continued):  Make use of the wireless communications capability of the MSP430, demonstrating its practical advantages;  Consolidate knowledge acquired during the previous laboratories, namely: From the MSP430 communications interfaces laboratories: –SPI mode to access the transceiver CC2500; –UART mode to interface with the IO console.

UBI >> Contents 7 Copyright 2009 Texas Instruments All Rights Reserved The application (1/2)  This laboratory establishes communications between various RF units;  The stations are identified by an ID, i.e., the address for presentation to the network. When a station wants to communicate with another station, it must use the address of the target station in the message;  The CC2500 has several ways to communicate, which determine the size of the messages exchanged;  In order to simplify the communication process, fixed- size address and data have been used (maximum message size 64 bytes). This corresponds to the size of the CC2500 FIFO.

UBI >> Contents 8 Copyright 2009 Texas Instruments All Rights Reserved The application (2/2)  CC2500 packages format:

UBI >> Contents 9 Copyright 2009 Texas Instruments All Rights Reserved The hardware (1/3)  The CC2500 is a radio frequency transceiver operating in the widely used ISM/SRD (Industrial-Scientific-Medical /Short-Range-Devices) 2.4 GHz frequency band;  It is a low-cost device with low power consumption, designed for consumer electronics applications.

UBI >> Contents 10 Copyright 2009 Texas Instruments All Rights Reserved The hardware (2/3)  The communications protocol uses very little data formatting. It is up to the user to define the communications protocol that best suits their application and implement their own software;  The CC2500 is a low pin-out device, because it integrates all the radio functions, except the antenna;  This device is not sufficiently independent that it can operate without the aid of a microcontroller;  When coupled to the MSP430, connection is made between: Access to internal registers: SPI interface belongs to the USCIB0 unit; Status pins: GDO0 and GDO2 (P2.6 and P2.7).

UBI >> Contents 11 Copyright 2009 Texas Instruments All Rights Reserved The hardware (3/3)  CC250 RF transceiver:

UBI >> Contents 12 Copyright 2009 Texas Instruments All Rights Reserved The software (1/2)  Internal structure:  Structured in layers: Base layer: Hardware abstraction layer. Responsible for separating the higher layers of software from the hardware; Middle SPI layer: Ensures the communication functions for the correct operation of CC2500; UART layer: Provides connection to the PC via RS232; CC2500 layer: Access and control functions controlling the CC2500 (SPI and the GPIO); Application layer: Uses the features offered by layers at a lower level to implement the tasks necessary for the correct operation of the application.

UBI >> Contents 13 Copyright 2009 Texas Instruments All Rights Reserved The software (2/2)  Software structure:

UBI >> Contents 14 Copyright 2009 Texas Instruments All Rights Reserved Configuration (1/3)  Clearly defined start-up of the multiple hardware modules and the various software modules;  Important: The unit’s address needs to be changed during compilation, to allocate a unique address.

UBI >> Contents 15 Copyright 2009 Texas Instruments All Rights Reserved Configuration (2/3)  Remote station code:  Composed of two interrupt service routines (ISR) and two buffers: Port1 ISR Port2 ISR

UBI >> Contents 16 Copyright 2009 Texas Instruments All Rights Reserved Configuration (3/3)  Remote station code: Port1 ISR: –Enabled by the GDO0, which causes a L-H transition when it receives a valid Sync_Word; –H-L transition at the end of a message reception; –Received message contents to IO console (RS232). Port2 ISR: Generated when the button is pressed, sending the signal announcing the presence of the remote station; Two buffers used to hold the messages: –Transmit buffer is used to build the message for later transmission; –The receive buffer is used to hold the data read from the CC2500 FIFO after receiving a message.

UBI >> Contents 17 Copyright 2009 Texas Instruments All Rights Reserved Algorithms (1/2)  Transmission algorithm implemented by Port2 ISR:

UBI >> Contents 18 Copyright 2009 Texas Instruments All Rights Reserved Algorithms (2/2)  Reception algorithm used by the Port1 ISR in both stations:

UBI >> Contents 19 Copyright 2009 Texas Instruments All Rights Reserved New challenges  The messages typed into the IO console for a particular address would be sent by wireless support to the console addressed.  To achieve this objective, it is useful to define a small set of user-defined commands, such as: Address allocation at the local station; Address allocation at the remote station; Sending a message; Neighbourhood screening of possible talking partners; Among others…

UBI >> Contents 20 Interrupt Introduction (1/3) WWhen MSP430 processor executes the following code, it will loop forever; QQuestion: How can it execute other codes that handle external events, e.g. I/O, timer? StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL SetupP1 bis.b #001h,&P1DIR ; P1.0 output Mainloop xor.b #001h,&P1OUT ; Toggle P1.0 Wait mov.w #050000,R15 ; Delay to R15 L1 dec.w R15 ; Decrement R15 jnz L1 ; Delay over? jmp Mainloop ; Again

UBI >> Contents 21 Interrupt Introduction (2/3)  Option 1:  Put codes that handle external events in your main program  polling ; StopWDT mov.w #WDTPW+WDTHOLD,&WDTCTL SetupP1 bis.b #001h,&P1DIR ; P1.0 output Mainloop xor.b #001h,&P1OUT ; Toggle P1.0 Wait mov.w #050000,R15 ; Delay to R15 L1 dec.w R15 ; Decrement R15 jnz L1 ; Delay over? bit.b #B1,&P2IN ; Test bit P2IN jnz ButtonUp ; Jump if not zero bis.b #LED1,&P2OUT ; Turn LED1 on ButtonUp: jmp Mainloop ; Again

UBI >> Contents 22 Interrupt Introduction (3/3) OOption 2: KKeep your program unchanged and force the processor to jump to the code handling the external event when that event occurs. RRequirements: MMust know when the event occurs; MMust let the processor know where to jump to execute the handling code; MMust not allow your program know!!  you program must execute as if nothing happens;  Must store and restore your program state. This is called interrupt!

UBI >> Contents 23 Interrupt: Processor's Perspective (1/2)  Interrupts are triggered when certain events occur;  Usually done by sending a signal to one of the processor’s IRQ (interrupt request) pins.

UBI >> Contents 24 Interrupt: Processor's Perspective (2/2)  An interrupt signal stops processor at the next instruction and the processor saves the address of the next instruction on the stack;  Jumps to a specific interrupt service routine (ISR).  ISR is basically a subroutine to perform operations to handle the interrupt with a RETURN at the end.  It is common to save the register contents onto the stack (saving the state) and restoring them at the end of the ISR (restoring the state).

UBI >> Contents 25 Interrupt Service Routine (1/2)  The following shows an example of an ISR: Task CodeISR... MOVE R1, R7 MUL R1, 5 PUSH R1 ADD R1, R2PUSH R2 DIV R1, 2... JCOND ZERO, END;ISR code comes here SUBTRACT R1, R POP R2...POP R1 END: MOVE R7, R1RETURN...

UBI >> Contents 26 Interrupt Service Routine (2/2)  An ISR is like a subroutine, invoking similar operations;  Subroutine:  Program has total control of when to call and jump to a subroutine.  ISR:  Program is forced by hardware signals to jump to an ISR at an unpredictable time, not by its control.

UBI >> Contents 27 Disabling Interrupts  Programs may disable interrupts  In most cases the program can select which interrupts to disable during critical operations and which to keep enabled by writing corresponding values into a special register;  Nonmaskable interrupts cannot be disabled and are used to indicate power failures or serious event.  Certain processors assign priorities to interrupts  Allowing programs to specify a threshold priority;  Only interrupts having higher priorities than the threshold are enabled and the ones below it are disabled.

UBI >> Contents 28 Where to Put ISR Code?  Challenges:  Locations of ISRs should be fixed so that the processor can easily find them;  Different ISRs may have different lengths  Hard to track their starting addresses;  Application programs may supply their own ISRs; thus ISR codes may change dynamically.  Possible solutions:  ISR is at a fixed location, e.g., in 8051, the first interrupt pin always causes 8051 to jump to 0x0003;  A table in memory contains addresses of ISR  The table is called interrupt vector table.

UBI >> Contents 29 How to Know Who Interrupts?  Simple answer: according to interrupt signal  One interrupt signal corresponds to one ISR;  Difficult problem: same interrupt signal shared by several devices/events  Option 1: inside the corresponding ISR, poll and check these devices/events in turn  Devices are passive;  Option 2: devices/events provide the address of ISRs  Devices are proactive;  Vectored interrupt.

UBI >> Contents 30 Some Common Questions  Can a processor be interrupted in the middle of an instruction?  Usually not;  Exceptions: critical hardware failure, long-running instructions (e.g. moving data in memory).  If two interrupts occur at the same time, which ISR does the process do first?  Prioritize the interrupt signals.  Can an interrupt signal interrupt another ISR?  Interrupt nesting usually allowed according to priority;  Some processor may require re-enabling by your ISR.  What happens when an interrupt is signaled while the interrupt is disabled?  Processors usually remember the interrupt signals and jump to the ISR when the interrupt is enabled.

UBI >> Contents 31 Interrupt Vector Table Interrupt SourceInterrupt Flag System Interrupt Word AddressPriority Power-up External Reset Watchdog Timer+ Flash key violation PC out-of-range PORIFG RSTIFG WDTIFG KEYV Reset0FFFEh31 (highest) NMI Oscillator Fault Flash memory access violation NMIIFG OFIFG ACCVIFG Non-maskable Non-maskable Non-maskable 0FFFCh30 0FFFAh29 0FFF8h28 0FFF6h27 Watchdog Timer+WDTIFGmaskable0FFF4h26 Timer_A2TACCR0 CCIFGmaskable0FFF2h25 Timer_A2TACCR1 CCIFG TAIFG maskable0FFF0h24 0FFEEh23 0FFECh22 ADC10ADC10IFGmaskable0FFEAh21 USIUSIIFG USISTTIFG maskable0FFE8h20 I/O Port P2 (2)P2IFG.6 P2IFG.7 maskable0FFE6h19 I/O Port P1 (8)P1IFG.0 to P1IFG.7 maskable0FFE4h18 0FFE2h17 0FFE0h16 Unused0FFDEh to 0FFCDh15 - 0

UBI >> Contents 32 Interrupt Latency  Interrupt latency is the amount of time taken to respond to an interrupt. It depends on:  Longest period during which the interrupt is disabled;  Time to execute ISRs of higher priority interrupts;  Time for processor to stop current execution, do the necessary ‘bookkeeping’ and start executing the ISR;  Time taken for the ISR to save context and start executing instructions that count as a ‘response’.  Make ISRs short  Factors 2 and 4 are controlled by writing efficient code that are not too long ;  Factor 3 depends on HW, not under software control.

UBI >> Contents 33 Sources of Interrupt Overhead  Handler execution time  Interrupt mechanism overhead  Register save/restore  Pipeline-related penalties  Cache-related penalties