CS4101 嵌入式系統概論 Program Organization Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430 Microcontroller.

Slides:



Advertisements
Similar presentations
1 Modeling Query-Based Access to Text Databases Eugene Agichtein Panagiotis Ipeirotis Luis Gravano Computer Science Department Columbia University.
Advertisements

YOSI! BLUE (30 sec play) Ball moves to X1 from X2
An Introduction to Calculus. Calculus Study of how things change Allows us to model real-life situations very accurately.
SNFS: The design and implementation of a Social Network File System Ch. Kaidos, A. Pasiopoulos N. Ntarmos, P. Triantafillou University of Patras.
Suggested Activities Unit 1: Unraveling the Problem- Solving Process.
Maximal Independent Subsets of Linear Spaces. Whats a linear space? Given a set of points V a set of lines where a line is a k-set of points each pair.
Data Flow Diagram (DFD) Overview
Logical DFM 1 Logical DFDs Objective – To capture the essence of the current system. Start with for totally new systems or where existing system is highly.
DCSP-20 Jianfeng Feng Department of Computer Science Warwick Univ., UK
MANE 4240 & CIVL 4240 Introduction to Finite Elements
Lab 11 : Memory System Fundamentals :
PROLOG MORE PROBLEMS.
1 Machine Learning: Lecture 1 Overview of Machine Learning (Based on Chapter 1 of Mitchell T.., Machine Learning, 1997)
ECBL: An Extended Corner Block List with Solution Space including Optimum Placement Shuo Zhou,Sheqin Dong, Xianlong Hong,Yici Cai Dept. of Computer Science.
BASED ON THE TUTORIAL ON THE BOOK CD Verilog: Gate Level Design 6/11/
Inverting a Singly Linked List Instructor : Prof. Jyh-Shing Roger Jang Designer : Shao-Huan Wang The ideas are reference to the textbook “Fundamentals.
2 x0 0 12/13/2014 Know Your Facts!. 2 x1 2 12/13/2014 Know Your Facts!
2 x /18/2014 Know Your Facts!. 11 x /18/2014 Know Your Facts!
2 x /10/2015 Know Your Facts!. 8 x /10/2015 Know Your Facts!
2.4 – Factoring Polynomials Tricky Trinomials The Tabletop Method.
P roblem S olving I nnovator Solving Tomorrows Problems Today User Help The help feature is found through out the PSI.This enables the user to gain a.
15 February 2007IASTED Software Engineering 2007, Innsbruck1 Embedded Functional Programming in Hume Gergely Patai Péter Hanák
1 Lecture 5 PRAM Algorithm: Parallel Prefix Parallel Computing Fall 2008.
A man-machine human interface for a special device of the pervasive computing world B. Apolloni, S. Bassis, A. Brega, S. Gaito, D. Malchiodi, A.M. Zanaboni.
5 x4. 10 x2 9 x3 10 x9 10 x4 10 x8 9 x2 9 x4.
If, we assume that a number of variables observed (latent variables), then what the method does is to extract a group of indicators to characterize a variable.
Parallel algorithms for expression evaluation Part1. Simultaneous substitution method (SimSub) Part2. A parallel pebble game.
Feature Selection for Pattern Recognition J.-S. Roger Jang ( 張智星 ) CSIE Dept., National Taiwan University ( 台灣大學 資訊工程系 )
DIRECTIONAL ARC-CONSISTENCY ANIMATION Fernando Miranda 5986/M
Linear Programming – Simplex Method: Computational Problems Breaking Ties in Selection of Non-Basic Variable – if tie for non-basic variable with largest.
The Problem of K Maximum Sums and its VLSI Implementation Sung Eun Bae, Tadao Takaoka University of Canterbury Christchurch New Zealand.
Chapter 8: The Solver and Mathematical Programming Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University.
Computational Facility Layout
Shannon Expansion Given Boolean expression F = w 2 ’ + w 1 ’w 3 ’ + w 1 w 3 Shannon Expansion of F on a variable, say w 2, is to write F as two parts:
XDI RDF Cell Graphs V This document introduces a notation for graphing XDI RDF statements called cell graphing. The motivation is to have an.
1 General Structural Equation (LISREL) Models Week 3 #2 A.Multiple Group Models with > 2 groups B.Relationship to ANOVA, ANCOVA models C.Introduction to.
0 x x2 0 0 x1 0 0 x3 0 1 x7 7 2 x0 0 9 x0 0.
Simplex (quick recap). Replace all the inequality constraints by equalities, using slack variables.
Select Team Man Up Offense: Greyhound. Greyhound: Level of Play Greyhound is appropriate for teams with good stickwork that are capable of executing the.
7x7=.
CS4101 嵌入式系統概論 Design and Development 金仲達教授 國立清華大學資訊工程學系 Slides from Computers as Components: Principles of Embedded Computing System Design, Wayne Wolf,
Technical Specification / Schedule Department of Computer Science and Engineering Michigan State University Spring 2007 Team : CSE 498, Collaborative Design.
組合語言與系統程式 Hsung-Pin Chang Department of Computer Science National Chung Hsing University.
Embedded Computer Systems Chapter5: Program design and analysis Eng. Husam Y. Alzaq Islamic University of Gaza 1 © 2010 Husam Alzaq Computers as Components.
6. & 7. Teams: Technical Specification / Schedule Project Title Team Member 1 Team Member 2 Team Member 3 Team Member 4 Department of Computer Science.
6. & 7. Team Technical Specifications and Schedule Wayne Dyksen Brian Loomis Department of Computer Science and Engineering Michigan State University Spring.
CS4101 嵌入式系統概論 Software UART Revisited Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430.
CS4101 嵌入式系統概論 Freescale Tower System Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from
© 2008 Wayne Wolf Overheads for Computers as Components 2nd ed. Program design and analysis Software components. Representations of programs. Assembly.
1 Introduction to UML Interface and packages 即時與嵌入式系統實驗試 李榮華.
Computer Science An Overview Allen C.-H. Wu/Arbee L.P. Chen Computer Science Department Tsing Hua University.
Introduction In this lab , we will learn
Pre-requisite for 20+ ECE Courses
Outline Introduction to NuMaker TRIO Programming environment setup
Introduction In this lab , we will learn
Recap More and more physical things will be augmented or embedded with computing Things become “smarter” Computing becomes ubiquitous An embedded system.
Introduction Why low power?
CS4101 嵌入式系統概論 General Purpose IO
CS4101 Introduction to Embedded Systems Lab 12: Task Synchronization
CS4101 Introduction to Embedded Systems Lab 1: General Purpose IO
CS4101 Introduction to Embedded Systems Lab 9: NuMaker ADC and LCD
CS4101 嵌入式系統概論 General Purpose IO
CS4101 Introduction to Embedded Systems Design and Implementation
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 2: Timer and Clock Prof. Chung-Ta King Department of Computer Science National.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 3: Interrupt Prof. Chung-Ta King Department of Computer Science National Tsing.
National Tsing Hua University CS4101 Introduction to Embedded Systems Lab 6: Serial Communication Prof. Chung-Ta King Department of Computer Science National.
Implementing real-time convolution
CS4101 嵌入式系統概論 RTOS Prof. Chung-Ta King Department of Computer Science
CSE 498, Collaborative Design
CS4101 嵌入式系統概論 Device Drivers
Presentation transcript:

CS4101 嵌入式系統概論 Program Organization Prof. Chung-Ta King Department of Computer Science National Tsing Hua University, Taiwan ( Materials from MSP430 Microcontroller Basics, John H. Davies; Computers as Components: Principles of Embedded Computing System Design, Wayne Wolf; An Embedded Software Primer, David E. Simon )

1 Outline  Embedded program design patterns  Embedded software architecture

2 Embedded Program Design Pattern  A design pattern is a generalized description of a certain type of programs that can be customized and used in different circumstances Designer fills in details to customize the pattern to a particular programming problem Help developers to identify essential elements of the system and facilitate the development of embedded software  Two patterns introduced here Data stream pattern State machine pattern

3 Data Stream Pattern  Commonly used in signal processing: New data constantly arrives, e.g., from ADC Each datum has a limited lifetime Processing a datum requires previous data elements  Use a circular buffer to hold the data stream  shift window x1x2x3x4x5x6 t1t1 t2t2 t3t3 Data stream x1x2x3x4 Circular buffer x5x6

4 Circular Buffer  Indexes locate currently used data, current input data: d1 d2 d3 d4 time t1 use input d5 d2 d3 d4 time t1+1 use input

5 Example: FIR Filter int circ_buffer[N], circ_buffer_head = 0; int c[N]; /* coefficients */ … int ibuf, ic; for (f=0, ibuff=circ_buff_head, ic=0; ic<N; ibuff=(ibuff==N-1?0:ibuff++), ic++) f = f + c[ic]*circ_buffer[ibuf];

6 State Machine Pattern  Identify states in the problems and describe the state transitions in a state machine State machine keeps internal state as a state variable, changes state based on inputs and performs operations on state transitions  State machine is useful in many contexts: Parsing user input Responding to complex stimuli Controlling sequential outputs For control-dominated code, reactive systems

7 Recall Basic Lab of Lab 7 FFlash green LED at 1 Hz using interrupt from Timer_A, driven by SMCLK sourced by VLO. While green LED flashing at 1 Hz, pushing the button flashes red LED at 2Hz and releasing the button turns off red LED. Use low-power mode as much as possible. HHow do you organize your program? IIf apply state machine pattern, how many states can you identify?

8 State Machine of Lab 7 WWhy don’t we consider the flashing green LED? BTN_offBTN_on no P1.3 in P1.3 in/set red LED flashing, set P1.3 edge P1.3 in/reset red LED flashing, set P1.3 edge no P1.3 in an event triggering interrupt works to do in ISR

9 State Table of Lab 7  From the state machine, we can set up a state transition table with a column for the actions associated with each transition Present state Enable input Next state Actions BTN_off no P1.3BTN_offnone P1.3BTN_on set red LED flashing, set P1.3 edge BTN_on no P1.3BTN_onnone P.1.3BTN_off reset red LED flashing, set P1.3 edge

10 C Code Structure  Create a variable to record the state  State table can be implemented as a switch Cases define states States can test inputs, make state transitions, perform corresponding actions Switch can be executed repetitively (polling) or invoked by interrupts (in ISR) switch (state) { case state1: … case state2: … }

11 Outline  Embedded program design patterns  Embedded software architecture

12 Embedded Software Architecture  Basic architecture to put your code to run  Most important factor in choosing architecture:  How much control on system responses? Depending on system requirements, costs, etc. e.g., whether must respond rapidly to many different events and that has various processing requirements, with different deadlines and priorities, etc.  Four software architectures are introduce here Round-robin, interrupt-driven, task queue, real-time operating system (RTOS)

13 Round-Robin  Check each event or I/O device in turn and service them as needed A C code written for it would consist of a switch-case loop that performs functions based on the detected events

14 Round-Robin  Simplest architecture without interrupts or shared-data concerns  no priority, no preemption, no control of responses  Problems: When a device needs response in less time than it takes the CPU to loop through in the worst case, e.g., device Z needs <7 ms to respond, but A and B take 5 ms each to process When a device needs lengthy processing  worst case response time will be as bad as that Architecture is not robust  addition of a single device might cause all deadlines to be missed

15 Interrupt-Driven  Events trigger interrupts, which perform corresponding actions in ISRs Most of our labs use this architecture When there is no event to handle, main function goes into low power modes  Characteristics: If no interrupt allowed inside an interrupt  non-preemptive Execution order depends on the order and/or priority of interrupts (not fixed as in round-robin)  limited control of responses

16 Task Queue  All the labs we have studied so far perform very simple work on interrupts.  In practice, an event may trigger complex computations, which may not be suitable for processing within ISRs. Example: Need to handle button events while in the middle of sending a byte to the PC using software UART. If the button event requires more time to process than the duration of transmitting a single bit, we may miss the deadline to transmit the next bit.  Solution: move non-critical works out of ISR

17 Task Queue  Interrupts for checking events and urgent works and main loop proceeds with follow-up works ISRs put action requests in some priority queue, and main function picks next task from queue for works #pragma vector=EVENTA_VECTOR __interrupt void EventA_ISR(void) { // put event A request in queue } void main (void) { while (TRUE) { // pick next request from queue // process corresponding actions } }

18 Task Queue  More control over priorities and better response Events can be assigned priorities, giving better responses especially for devices with hard deadlines  Disadvantage: Complexity of working with shared-data variables Limited task scheduling capability and handle scheduling in application  need to wait till current action done before next scheduling Difficult to implement preemptions of low-priority tasks

19 Real-Time Operating System  Task code is separated into threads  ISRs handle important works and request corresponding threads be scheduled RTOS will decide which thread to run based on urgency (priority) RTOS can suspend a thread to run another (usually higher priority) one  Response is independent of task code length Changes to code lengths of low priority tasks don’t affect higher priority tasks.

20 Selecting an Architecture  Select the simplest architecture meeting response requirements.  RTOSs should be used where response requirements demand them.  Hybrid architectures can be used if required. e.g. you can use an RTOS with a low-priority task polling the relatively slower hardware.