Program Modeling Concepts:

Similar documents
Inter-Process Communication and Synchronization of Processes, Threads and Tasks:

Chapter 09. Programming in Assembly

Embedded Systems and Software

Lesson-1: PROGRAM MODELS

Lesson-3: Counters and Timers

Chapter 2. Overview of Architecture and Microcontroller-Resources

Chapter 6 PROGRAMMING THE TIMERS

8051 Peripherals. On-Chip Memory Timers Serial Port Interrupts. Computer Engineering Timers

Interrupts and Timers

1 CONTROL CHARACTERS AND CONTROL CODES

Chapter 6 PROGRAMMING THE TIMERS

Grundlagen Microcontroller Interrupts. Günther Gridling Bettina Weiss

Computer Systems II. First Two Major Computer System Evolution Steps

This chapter describes the SIMATIC instruction set for the S7-200.

Interrupt vectors for the 68HC912B32. The interrupt vectors for the MC9S12DP256 are located in memory from 0xFF80 to 0xFFFF.

F. Wagner April 2003 revised April any Boolean expression can be represented by an OR combination of AND expressions

real-time kernel documentation

AFRecorder 4800R Serial Port Programming Interface Description For Software Version 9.5 (Last Revision )

ECE 449 OOP and Computer Simulation Lecture 09 Logic Simulation

e-pg Pathshala Subject: Computer Science Paper: Embedded System Module: Interrupt Programming in Embedded C Module No: CS/ES/20 Quadrant 1 e-text

Generalised User Interface for Embedded Applications using an LCD screen and keypad.

Designing Responsive and Real-Time Systems

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

Sequencing and control

PLC AUTOMATION SYSTEM LABORATORY. Manual

PROGRAM MODELING CONCEPTS UNIT IV

1. Attempt any three of the following: 15

University of Texas at El Paso Electrical and Computer Engineering Department. EE 3176 Laboratory for Microprocessors I.

8032 MCU + Soft Modules. c = rcvdata; // get the keyboard scan code

Inter-Process Communication and Synchronization of Processes, Threads and Tasks: Lesson-3: Task and Task States

One and a half hours. Section A is COMPULSORY

8051 I/O and 8051 Interrupts

Chapter 05: Basic Processing Units Control Unit Design. Lesson 15: Microinstructions

Single thread Scheduler All processes called once each sample

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz III

Lesson 5: Software for embedding in System- Part 2

Measuring Duty Cycles with an Intel MCS-51 Microcontroller

Hello and welcome to this Renesas Interactive module that covers the Independent watchdog timer found on RX MCUs.

Real Time & Embedded Systems. Final Exam - Review

Announcements! P1 part 1 due next Tuesday P1 part 2 due next Friday

Chapter 09. Programming in Assembly

EE178 Lecture Verilog FSM Examples. Eric Crabill SJSU / Xilinx Fall 2007

Xbee module configuration from a µcontroller

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

State Machine Descriptions

Fujitsu Microelectronics Europe Application Note MCU-AN E-V10 FR FAMILY 32-BIT MICROCONTROLLER MB91460 REAL TIME CLOCK APPLICATION NOTE

Chapter 15 ARM Architecture, Programming and Development Tools

Principles of Testing and Analysis. COMP 4004 Fall Notes Adapted from Dr. A. Williams

Design UART Loopback with Interrupts

CHAPTER 11 INTERRUPTS PROGRAMMING

Timer 32. Last updated 8/7/18

Project Final Report Internet Ready Refrigerator Inventory Control System

Sequential Logic Design

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

ECE 122. Engineering Problem Solving with Java

{ int i,j; for(i=0;i<count;i++) for(j=0;j<1275;j++); }

Lab 3a: Scheduling Tasks with uvision and RTX

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Timers and event handling

C:\CYGNAL\Examples\C8051F02x\C\Edu_Board_Source_Code\Magcard.c

80C51 Block Diagram. CSE Overview 1

8051 Microcontroller Interrupts

Chapter 8: Computation models 8-1

Chapter 11: Interrupt On Change

The 8051 microcontroller has two 16-bit timers/counters called T0 and T1.

Appendix A Pseudocode of the wlan_mac Process Model in OPNET

ECE 271 Microcomputer Architecture and Applications University of Maine

Spartan-3 MicroBlaze Sample Project

Interrupt/Timer/DMA 1

WARNING for Autumn 2004:

204111: Computer and Programming

OPERATING SYSTEMS. Systems with Multi-programming. CS 3502 Spring Chapter 4

COE 405 Behavioral Descriptions in VHDL

This is Your Software Security Access Key: DO NOT LOSE IT!

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture 9. Timer Operations and Programming

Name Section: M/W T/TH Number Definition Matching (8 Points)

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Interrupts, timers and counters

Signature: 1. (10 points) Basic Microcontroller Concepts

SECTION 5 RESETS AND INTERRUPTS

Building on the foundation. Now that we know a little about cout cin math operators boolean operators making decisions using if statements

EE414 Embedded Systems Ch 9. State Machines

Programmed I/O (busy( wait) ) method for ports and devices, and the need for interrupt driven IOs

Part B Questions. Unit I

Introduction to Processes

Timer Counter and Interrupt. Equation (16 bits counter, Mode 1, 16MHz):

UNIVERSITY OF CONNECTICUT. ECE 3411 Microprocessor Application Lab: Fall Quiz II

Software Engineering. Page 1. Objectives. Object-Behavioural Modelling. Analysis = Process + Models. Case Study: Event Identification

CPUs. Input and output. Supervisor mode, exceptions, traps. Co-processors. Computers as Components 4e 2016 Marilyn Wolf

Exceptions, Case Study-Exception handling in C++.

Module 9: Virtual Memory

EE4390 Microprocessors

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

#define FACEOFF_DEBUG /**************************************************************************** Module FaceOffSM.c

Parallel versus serial execution

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

F2MC-8FX EEPROM Library

Controller FSM Design Issues : Correctness and Efficiency. Lecture Notes # 10. CAD Based Logic Design ECE 368

2008 Chapter-8 L1: "Embedded Systems - Architecture, Programming and Design", Raj Kamal, Publs.: McGraw-Hill, Inc.

Transcription:

Program Modeling Concepts: Lesson-6: FSM STATE TABLE AND ITS APPLICATIONS 1

FSM State Table A state table can then be designed for representation of every state in its rows. The following six columns are made for each row. 1. Present State name or identification 2. Action (s) at the state until some event(s) 3. The events (tokens) that cause the execution of state transition function 4. Output (s) from the state output function (s) 5. Next State 6. Expected Time Interval for finishing the transitions to a new state after the event 2

Coding using while ( ) for each row while (presentstate) {action ( ); if (event =...; token =... ) {output =...; statetransitionfunction ( ); };} 3

Coding using switch and case for Switch (State) each row Case presentstate: action ( ); if (event =...; token =... ) {output =...; statetransitionfunction ( ); };} 4

Meaning of terms presentstate a Boolean variable, which is true as long as the present state continues and turns false on transition to the next. The action ( ) is a function that executes at the state. If certain events occur and tokens are received (for example, clock input in a timer), a state transition function, statetransitionfunction, is executed which also makes presentstate = false and transition occurs to the next state by setting nextstate (a Boolean variable) = true. 5

Example Mobile phone key 5 of T9 keypad A mobile phone T9 keypad key marked 5 has five states. It undergoes transitions from initial state (0, 5) as follows: (0, 5) (1, 5) (1, j) (1, k) (1, l) (l, 5) (1, j). 6

Example State transition at key 5 of T9 keypad Occurs when key-input flag KF = 1 (set). State transition occurs when TF = 0 and KF = 1. The transition resets the key. The timer starts on key-interrupt and when is in ON state and the timer run flag TR = true. 7

Example State transition at key 5 of T9 keypad When timer is off or till timer timeouts TR = 0. When count = x, timer flag TF = 0 (false) before timeout. Time occurs when count x = compare register loaded for 1 s. After 1 s, the TF = true. There are twelve finite number of states of the key and timer together. 8

FSM states in a program model of an ACVM Key5 Interrupt flag = 1 or C = 1 S(0,5) S(1, i) C = 1 C = 1 C = 1 S(1, j) S(1, k) S(1, l) C = 1 if (key5interruptflag == 1 & TR == 1 & TF == 0) then C = 1 else if (TR == 0 & TF == 1) then C = 0; /* TR = 1 means timer is running after key interrupt, TF = 1 means timer timeout. C = 1 means that key interrupt has occurred, timer then started running but 1s timeout flag is no yet set. 9

States and rows in State table for FSM for key 5 Present State Event Next State on event Key TR TF KF KF Count Key TR TF KF (0, 5) 0 0 0 1 x (1, j ) 1 0 0 (1,5) 1 0 0 1 x (1, j ) 1 0 0 (1, j ) 1 0 0 1 x (1, k) 1 0 0 (1, k) 1 0 0 1 x (1, l) 1 0 0 (1, l) 1 0 0 1 x (1, 5) 1 0 0 (1,5) 0 1 0 0 0 (1,5) 0 0 0 (1, j ) 0 1 0 0 0 (1,j) 0 0 0 (1, k) 0 1 0 0 0 (1,k) 0 0 0 (1, l) 0 1 0 0 0 (1,l) 0 0 0 10

States and rows in State table for FSM for key 5 Count = x initial count register value. = x means counts greater than x and less than a compare register value set for 1 s timeout. TR = 0 means timer stopped. TR =1 means timer running after loading a value in compare register for capture time out after 1 s. TF = 1 means timer compare timeout. KF = 1 key press event. KF = 0 means key read or initial inactive 11

# define true 1 # define false 0 C Code from the Table # define initialstate 05000 # define state1 15100 # define state2 1j100 # define state3 1k100 # define state4 1l100 # define state5 15010 # define state6 1j010 12

C Code from the Table # define state7 1k010 # define state8 1l010 # define state9 15000 # define state10 1j000 # define state11 1k000 # define state12 1l000 13

C Code from the Table void Key5FSM ( ) { char [ ] state; initialstate = 05000 while (true) { /* An infinite loop */ /*----------------------------------------------------*/ /* function display ( x ) shows character x on the screen and function cursor_next ( ) moves the cursor position to next when keyiing in an SMS text message. SWI is software interrupt instruction */ 14

C Code from the Table Switch (State) { /*******************************/ initialstate: if ((KF == 1) && Count == 0)) { SWI timerstart; /* Execute Interrupt routine to start the timer */ display ( 5 ); State = State1;} break; /******************************/ 15

C Code from the Table State1: if ((KF == 1) && Count == x)) { SWI timerrestart; /* Execute Interrupt routine to restart the timer */ display ( j ); State = State2;} break; 16

C Code from the Table State2: if ((KF == 1) && Count == x)) { SWI timerrestart; /* Execute Interrupt routine to restart the timer */ display ( k ); State = State3;} break; /***************************/ 17

C Code from the Table State3: if ((KF == 1) && Count == x)) { SWI timerrestart; /* Execute Interrupt routine to restart the timer */ display ( k ); State = State4;} break; 18

C Code from the Table State4: if ((KF == 0) && Count == x)) { SWI timerrestart; /* Execute Interrupt routine to restart the timer */ display ( l ); State = State5;} break; /*****************************/ 19

C Code from the Table State5: if ((KF == 0) && Count == 0)) { SWI timerreset; /* Execute Interrupt routine to reset and stop the timer */ display ( 5 ); cursor_next ( ); State = State9;} exit ( ); /*********************************** *******************************/ 20

C Code from the Table State6: if ((KF == 0) && Count == 0)) { SWI timerreset; /* Execute Interrupt routine to reset and stop the timer */ display ( j ); cursor_next ( ); State = State10;} exit ( ); 21

C Code from the Table State7: if ((KF == 0) && Count == 0)) { SWI timerreset; /* Execute Interrupt routine to reset and stop the timer */ display ( k ); cursor_next ( ); State = State11;} exit ( ); /*********************************** *********************************/ 22

C Code from the Table State8: if ((KF == 0) && Count == 0)) { SWI timerreset; /* Execute Interrupt routine to reset and stop the timer */ display ( l ); cursor_next ( ); State = State12;} exit ( ); /*********************************** *******************************/ 23

C Code from the Table } /*------End of Switch -case ---------------*/ } /* End of While infinite loop */ } /* End of Key5FSM */ 24

Summary 25

We learnt When using a FSM model, a state table representation becomes very handy while en coding Use of state table for programming for the key 5 in mobile T9 keypad 26

End of Lesson 6 of Chapter 6 27