KyungHee Univ. 2-0 Chapter 2 Design of Software Systems.

Slides:



Advertisements
Similar presentations
Review: Interrupts & Timers
Advertisements

Lab7: Introduction to Arduino
10-1 EE 319K Introduction to Microcontrollers Lecture 10: Interrupts, Output Compare Periodic Interrupts Read Book Sections 9.1, 9.2, 9.4, 9.6.1, 9.6.2,
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
ECE 372 – Microcontroller Design Parallel IO Ports - Interrupts
Computer Systems/Operating Systems - Class 8
COMP3221: Microprocessors and Embedded Systems Final Exam Lecturer: Hui Wu Session 1, 2005.
Debouncing Switches Mechanical switches are one of the most common interfaces to a uC. Switch inputs are asynchronous to the uC and are not electrically.
1 Lecture 6 Performance Measurement and Improvement.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
1-1 Embedded Software Development Tools and Processes Hardware & Software Hardware – Host development system Software – Compilers, simulators etc. Target.
Programming I/O for Embedded System. Page 2 Overview Basis: A DE2 Computer Architecture Parallel I/O 7-Segment Display Basic Manipulating 7-Segment Display.
A. Frank - P. Weisberg Operating Systems Introduction to Cooperating Processes.
KyungHee Univ. 2-0 Parallel Port LCD Interface with the HD44780 Controller.
The 8051 Microcontroller architecture
KyungHee Univ. 2-0 Chapter 8 Parallel Port Interfaces.
Cortex-M3 Debugging System
1 Timing System Timing System Applications. 2 Timing System components Counting mechanisms Input capture mechanisms Output capture mechanisms.
System Calls 1.
USART interrupt.
제 12 장 Bus. kuic.kyonggi.ac.kr/~dssung 12.1 Why bus is needed ? 컴퓨터를 구성하는 요소들 (CPU, Memory, I/O) 이 정보를 교환하기 위해서는 통로가 필요함 통로를 구성하기 위한 대표적인 방법 MeshBus 장점.
KyungHee Univ. 1-0 문자열 입 · 출력 프로그램 작성 예. KyungHee Univ. 1-1  모니터에 문자열 출력 하는 프로그램 작성  표준 출력 장치에 문자를 출력 하는 함수 함수의 기본형 : void SCI_OutChar(letter)  문자를.
UNIT 8 Keypad Interface Contact Closure Counter Exceptions (Interrupts and Reset)
MICE III 68000/20/30 MICETEK International Inc. CPU MICEIII MICEView Examples Contents Part 1: An introduction to the MC68000,MC68020 and Part.
AVR CPU Core & 8 bit AVR Instruction Set
1 3-Software Design Basics in Embedded Systems. 2 Development Environment Development processor  The processor on which we write and debug our programs.
Ch. 9 Interrupt Programming and Real-Time Sysstems From Valvano’s Introduction to Embedded Systems.
ECE 371- Unit 11 Timers and Counters (“Stop Watches and Alarm Clocks”)
V 0.91 Polled IO versus Interrupt Driven IO Polled Input/Output (IO) – processor continually checks IO device to see if it is ready for data transfer –Inefficient,
KyungHee Univ. 2-0 Parallel Port LED Interfaces. KyungHee Univ. 2-1 Output LEDs.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
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.
Revised: Aug 1, ECE 263 Embedded System Design Lessons 23, 24 - Exceptions - Resets and Interrupts.
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
인터럽트의 개요 Interrupt의 처리 과정
1-1 Embedded Network Interface (ENI) API Concepts Shared RAM vs. FIFO modes ENI API’s.
Ch.5 Modular Programming From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12 Published by CENGAGE, 2010.
Other Chapters From the text by Valvano: Introduction to Embedded Systems: Interfacing to the Freescale 9S12.
Ethernet Driver Changes for NET+OS V5.1. Design Changes Resides in bsp\devices\ethernet directory. Source code broken into more C files. Native driver.
ECS642U Embedded Systems Digital I/O William Marsh.
NT Kernel CS Spring Overview Interrupts and Exceptions: Trap Handler Interrupt Request Levels and IRT DPC’s, and APC’s System Service Dispatching.
ECS642U Embedded Systems Cyclic Execution and Polling William Marsh.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
Computer System Architecture Dept. of Info. Of Computer. Chap. 13 Multiprocessors 13-1 Chap. 13 Multiprocessors n 13-1 Characteristics of Multiprocessors.
1 4-Development Environment Development processor  The processor on which we write and debug our programs Usually a PC Target processor  The processor.
Saxion University of Applied Sciences Advanced Microcontrollers A practical approach.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L05I Advanced Debugging on the RX600 Fatih Peksenar.
© 2000 Morgan Kaufman Overheads for Computers as Components Host/target design  Use a host system to prepare software for target system: target system.
EE 319K Introduction to Embedded Systems
Teaching Digital Logic courses with Altera Technology
9-4 The Shifter  Shifter shifts the value on Bus B  Right shift and Left shift Bidirectional shift register with parallel load First clock pulse 에 Bus.
بسم الله الرحمن الرحيم MEMORY AND I/O.
Chapter 7 Register & Register Transfer 7-1 Register and Register Enable 7-2 Register Transfers 7-3 Register Transfer Operations 7-5 Microoperations 7-6.
HCS12 Technical Training Module 15 – Break Module Slide 1 MOTOROLA and the Stylized M Logo are registered in the US Patent & Trademark Office. All other.
HJD Institute of Technical Education & Research- Kera(Kutch) The 8051 Microcontroller architecture PREPARED BY: RAYMA SOHIL( )
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Microprocessors A practical approach..
Chapter 3 General-Purpose Processors: Software
80C51 Block Diagram ECE Overview.
Timer/Counter Modified from Dr. Lam Phung’s Slides.
8051 Programming in C rhussin.
CSCI1600: Embedded and Real Time Software
EE 319K Introduction to Embedded Systems
Example 18 Pulse Train Using Interrupts
Fundamental Programming
MCO556 Timer System Exercise.
CSCI1600: Embedded and Real Time Software
Presentation transcript:

KyungHee Univ. 2-0 Chapter 2 Design of Software Systems

KyungHee Univ Device Drivers Basic Concept of Device Drivers  I/O 를 직접 수행하는 Routine 으로 시스템 또는 이용자 프로그램에 의하여 Call 된다.  여기서는 간단한 Serial Port 를 제어하는 Device Driver 를 예로 하여 설명 한다.  Device Driver 는 아래 예와 같은 Gate 기능을 수행하는 함수에 의하여 상위 레벨 Routine 과 연결 된다.

KyungHee Univ Design of a Serial Communications Interface (SCI) Device Drivers 1.Data structures: global (Private)  Private global data structures Private 의 의미는 오직 Driver 프로그램 내에서만 직접 Access 가능 Device Driver 의 이용자는 Driver 내의 Public function 을 통하여 Access 할 수 있다. 예 : OpenFlag, FIFO queue 2.Initialization routine (public, called by client once in the beginning)

KyungHee Univ Design of a Serial Communications Interface (SCI) Device Drivers 3.Regular I/O call (public, called by client to perform I/O)  Device 의 I/O 기능을 수행하는 Public function 으로  Prototypes 은 Header File (SCI.H) 에 작성 된다.  이용자는 이 함수를 통하여 Device Driver 를 이용하게 된다.  이용자를 위한 Prototypes 과 Document 는 SCI.H File 에 개발자를 위한 기능 설명은 SCI.C File 에 포함 한다.

KyungHee Univ Design of a Serial Communications Interface (SCI) Device Drivers 3.Regular I/O call (public, called by client to perform I/O) 예

KyungHee Univ Design of a Serial Communications Interface (SCI) Device Drivers 3.Regular I/O call (public, called by client to perform I/O) 예

KyungHee Univ Design of a Serial Communications Interface (SCI) Device Drivers 4.Support software (private)  Device Driver 기능 구현에 필요한 ( 도움이 되는 ) Private Function 과  Private Function : Private Function 의 Prototype 은 Header File 에 포함되지 않는다.  예 : Helper Function, Interrupt service routine 등

KyungHee Univ Object-Oriented Interfacing Encapsulated Objects Using Standard C Encapsulation : 함수와 변수를 하나의 class 에 포함하도록함. #include "HC12.H" #include "LCD12.H" #include "COP12.H" #include "Timer.H" void main(void){ char letter; int n=0; COPinit(); // Enable TOF interrupt to make COP happy LCDinit(); TimerInit() LCDString("Adapt812 LCD"); TimerMsWait(1000); LCDclear(); letter='a'-1; while(1){ if (letter=='z') letter='a'; else letter++; LCDputchar(letter); TimerMsWait(250); if(++n==16){ n=0; LCDclear(); }}} #include "LCD12.C" #include "COP12.C" #include "Timer.C" #include "VECTORS.C"  Program Main program with three modules.

KyungHee Univ Object-Oriented Interfacing Encapsulated Objects Using Standard C void TimerInit(void); void TimerMsWait(unsigned int time);  Program 2.20 Timer.H header file has public functions. 이 Public function 함수를 포함하고 있는 File Name 을 표시함

KyungHee Univ Object-Oriented Interfacing Encapsulated Objects Using Standard C unsigned int TimerClock; // private global, 이 파일 내에서만 access 됨 void TimerInit(void){ // public function TSCR |=0x80; // TEN(enable) TMSK2=0xA2; // TOI arm, TPU(pullup) timer/4 (500ns) TimerClock=2000; // 2000 counts per ms } void TimerWait(unsigned int time){ // private function TC5=TCNT+TimerClock; // 1.00ms wait TFLG1 = 0x20; // clear C5F while((TFLG1&0x20)==0){};} void TimerMsWait(unsigned int time){ // public function for(;time>0;time--) TimerWait(TimerClock); // 1.00ms wait }  Program 2.20 Timer.C implementation file defines all functions.

KyungHee Univ Portability Using Standard C /* 6812 PortC bits 1,0 are input, Port B bits 1,0 are output */ #defineOutPort (*(unsigned char volatile *)(0x0001)) #defineOutDDR (*(unsigned char volatile *)(0x0003)) #defineInPort (*(unsigned char volatile *)(0x0004)) #defineInDDR (*(unsigned char volatile *)(0x0006)) /* rate is the number of cycles/100usec */ #define rate 800 const struct State{ unsigned char Out; /* Output values */ unsigned int Time; /* Time in 100 탎 ec to wait in this state */ const struct State *Next[4]; /* Next state if input=0,1,2,3 */ }; typedef const struct State StateType; #define SA &fsm[0] #define SB &fsm[1] #define SC &fsm[2] StateType fsm[3]={ {0x01,5*rate,{SB,SA,SB,SC}}, /* SA out=1, wait= 500usec, next states */ {0x02,10*rate,{SC,SA,SB,SC}}, /* SB out=2, wait=1000usec, next states */ {0x03,20*rate,{SA,SA,SB,SA}} /* SC out=3, wait=2000usec, next states */ };  Program 2.22 Enhanced C implementation of a Mealy Finite State Machine. 변경 될 수 있는 Parameters 인 경우 #define macros 를 이용하여 정의 하면 Portability 를 증가 시킨다.

KyungHee Univ Portability Using Standard C void Wait(unsigned int delay){ int Endt; Endt=TCNT+delay; /* Time (125ns cycles) to wait */ while((Endt-(int)TCNT)>0); /* wait */ }; void main(void){ StateType *Pt; unsigned char Input; Pt=SA; /* Initial State */ OutDDR=0xFF; /* Make Output port outputs */ InDDR=0x00; /* Make Input port inputs */ TSCR=0x80; /* Enable TCNT, default rate 8 MHz */ while(1){ OutPort=Pt->Out; Wait(Pt->Time); /* Time to wait in this state */ Input=InPort&0x03; /* Input=0,1,2,or 3 */ Pt=Pt->Next[Input]; } };  Program 2.22 Enhanced C implementation of a Mealy Finite State Machine.

KyungHee Univ Thread Thread 와 Process 의 차이  Thread I/O Device 와 Global variables 를 공유함. Interrupt service routine 은 Background thread 이다. FIFO 는 Thread 사이의 Communication 에 이용될 수 있다.  FIFO 을 이용한 Key Input Thread 와 Printing Thread 사이의 Communication  Process I/O Device 와 Global variables 를 공유하지 않음. 서로 독립된 목표를 갖는다.

KyungHee Univ Thread Single-Threaded Execution  Thread 컴퓨터 프로그램 수행 시 프로세스 내부에 존재하는 수행 경로, 즉 일련의 실행 코드 Foreground Thread Embedded system 에서는 많은 경우 무한 Loop 를 포함함.

KyungHee Univ Thread Multithreading and Reentrancy  두개 이상의 Thread 에서 동시에 실행될 수 있는 Program Segment 는 Reentrant 한 Code 이다. Timmer INT 에 의 의하여 Background 에서 실행되는 INT Service Routine Key Stroke INT 에 의 의하여 Background 에서 실행되는 INT Service Routine

KyungHee Univ Recursion  Recursive Program 자기 자신을 Call 할 수 있는 Program 이다. Recursive routine 은 Reentrant 한 코드 이다. Recursive algorithms 은 프로그램 메모리를 적게 필요로 하고 효과적인 프로그램을 작성하게 한다. 그러나 큰 Stack space 를 필요로 하고, 실행 속도가 느리다.

KyungHee Univ Debugging Strategies Debugging Tools  Logic Analyzer 직접 Address/Data Bus 에 접속 하여 실시간 실행 결과를 관찰 할 수 있다. 관찰을 시작하는 순간에 Trigger ( 동기 ) 방법을 이해하여야 한다. 원 프로그램에 포함 되어 있는 Debugging 정보를 볼 수 없기 때문에 프로그램 내용을 이해하기 어렵다. 내부 Cache, Multiple instruction queues, Branch prediction, Internal Bus 등 고급 기능의 관찰이 어렵다.

KyungHee Univ Debugging Strategies Debugging Tools  In-circuit emulator(ICE) Processor 를 제거하고 해당 소켓에 Emulator 케이블을 연결. ICE 는 보통 PC 와 연동하여 PC 의 자원 (Editor, 하드 디스크, 프린터 등을 이용하여 효과적으로 Debugging 한다.

KyungHee Univ Debugging Strategies Debugging Tools  In-circuit ROM emulator 대부분의 Software-based Debugger 는 Software trap( 6812 에서 swi 명령 ) 을 이용하여 Breakpoint 기능을 실현한다. 프로그램이 ROM 에서 실행 되는 경우 이 기능을 이용할 수 없기 때문에 ROM emulator 를 필요로 한다.

KyungHee Univ Debugging Strategies Functional Debugging  Functional Debugging 가능한 Input 에 대하여 Output 이 예상되는 결과와 일치하는지를 검증한다 Single Stepping or Trace Breakpoints without Filtering Conditional Breakpoints Ex. If(count == 32) bkpt Instrumentation : Print Statements

KyungHee Univ Debugging Strategies Functional Debugging Instrumentation : Dump into Array without Filtering 조건 없이 Buffer 에 여유가 있는 한 무조건 Dump 함

KyungHee Univ Debugging Strategies Functional Debugging Instrumentation : Dump into Array with Filtering 조건을 만족하는 경우에만 Dump 함 Buffer 에 여유가 있는 경우에만 Dump 함

KyungHee Univ Debugging Strategies Functional Debugging Monitor using Fast Displays  Output Port 이용

KyungHee Univ Debugging Strategies Performance Debugging  System 의 Time Behavior 를 검증한다. System 이 Run 하고 있는 중, 예상 시간 내에 예상되는 I/O 가 얻어 지는 검증 한다 Instrumentation Measuring with an Independent Counter : TCNT 16 Bit counter TCNT 를 이용하여 시간 정보를 측정한다.

KyungHee Univ Performance Debugging Instrumentation Measuring with an Independent Counter : TCNT Instrumentation Output Port 프로그램 실행 속도 측정을 위한 신호를 Output Port 에 출력하고 오실로스코프 등의 장비로 시간을 측정한다 Measurement of Dynamic Efficiency 아래와 같은 3 가지 방법을 사용 할 수 있다.  Assembly Listing 을 이용한 Bus cycles count 방법  Internal Timer(TCNT) 를 이용한 처리 시간 측정 방법  Output pin 에 신호를 출력하고 Oscilloscope 또는 Logic Analyzer 를 이용한 시간 측정 방법

KyungHee Univ Debugging Strategies Performance Debugging Instrumentation Output Port 프로그램 실행 속도 측정을 위한 신호를 Output Port 에 출력하고 오실로스코프 등의 장비로 시간을 측정한다. 예 : Loop jsr Set jsr Calculate ; function under test jsr Clr bra loop

KyungHee Univ Measurement of Dynamic Effiency  Assembly Listing 을 이용한 Bus cycles count 방법

KyungHee Univ Debugging Strategies Performance Debugging  Internal Timer(TCNT) 를 이용한 처리 시간 측정 방법

KyungHee Univ Debugging Strategies Performance Debugging  Output pin 에 신호를 출력하고 Oscilloscope 또는 Logic Analyzer 를 이용한 시간 측정 방법

KyungHee Univ Profiling  Profiling 은 관심을 갖는 사항에 대하여 Time history 정보를 수집하여 분석하는 디버깅 방법이다 A Time/Position profile dumping into a data array 시간과 위치가 관심 사항 임

KyungHee Univ Profiling Profiling Using an Output Port  Output port 를 이용하여 Profile 을 관찰함.

KyungHee Univ Profiling Thread Profile Multiple Threads 가 실행될 경우 각 Thread 를 Output port pin 에 할당하여 각 Thread 가 실행되는 동안 해당 Pin 에 1 를 출력하여 이 신호를 Multiple-channel scope 로 관측하여 각 Thread 의 실행 Profile 를 알 수 있다.