ppt on moving msg display

download ppt on moving msg display

of 42

Transcript of ppt on moving msg display

  • 7/29/2019 ppt on moving msg display

    1/42

    REAL TIME PROCESSING

    WITH RTOS PORTING ON ARM

    PROCESSOR

    Student: S.D. Mali

    Guide: Prof. Dr.A.D.Jadhav

  • 7/29/2019 ppt on moving msg display

    2/42

    Contents

    Introduction Block diagram of system

    Block diagram details

    Design of the system flow

    System Design

    Experimentation

    Result and conclusion

    References

    Publications

  • 7/29/2019 ppt on moving msg display

    3/42

    INTRODUCTION

    Real-Time Systems Concepts

    -Real-time systems are characterized by the fact that severeconsequences will result if logical as well as timing correctness

    properties of the system are not met.

    There are two types of real-time systems: SOFT and HARD.

    In a SOFT real-time system, tasks are performed by the system as fastas possible, but the tasks don't have to finish by specific times.

    In HARD real-time systems, tasks have to be performed not onlycorrectly but on time.

    Most real-time systems have a combination of SOFT and HARDrequirements.

  • 7/29/2019 ppt on moving msg display

    4/42

    Most applications for real-time systems are embedded.

    Examples of embedded systems are:

    Process control: Food processing, Chemical plants.

    Automotive: Engine controls, Anti-lock braking systems.

    Office automation: FAX machines, Copiers.

    Computer peripherals: Printers, Terminals, Scanners,Modems,Robots.

    Aerospace: Flight management systems, Weapons systems, Jet

    engine controls.

    Domestic: Microwave ovens, Dishwashers, Washing machines.

  • 7/29/2019 ppt on moving msg display

    5/42

    BLOCK DIAGRAM OF SYSTEM

    Hardware

    RTOS

    Application

    Software

    Fig.1. BLOCK DIAGRAM OF SYSTEM

  • 7/29/2019 ppt on moving msg display

    6/42

    Block Diagram Details

    The block diagram consisting three main parts:

    RTOS

    Hardware

    Application Software

    Basic Concept of RTOS:

    RTOS is real time operating system . It is not necessary in small embedded systems. But it is

    necessary in system where scheduling of multiple tasks,ISRs ,devices is important with respect to real time

    constraints.

  • 7/29/2019 ppt on moving msg display

    7/42

    Operating system that provides the most basic services to

    application software running on a processor.

    Fig. 2. Basic Services Provided by a Real-Time Operating System.

  • 7/29/2019 ppt on moving msg display

    8/42

    Hardware

    ARM7-2148 board with LED , Serial port, (16x2Text)LCD and (4X4 matrix)Keyboard.

    Features of LPC2148 processor:

    - 16/32-bit ARM7TDMI-S microcontroller in a tiny

    LQFP64 package.

    - 40 kB of on-chip static RAM.- 512 kB of on-chip flash program memory.

    - 128 bit wide interface/accelerator enables high speed 60

    MHz operation.

  • 7/29/2019 ppt on moving msg display

    9/42

    - In-System/In-Application Programming (ISP/IAP) viaon-chip boot-loader software.

    - One or two (LPC2141/2 vs. LPC2144/6/8) 10-bit A/Dconverters provide a total of 6/14analog inputs, with

    conversion times as low as 2.44 s per channel.- Single 10-bit D/A converter provides variable analog

    output.

    - Two 32-bit timers/external event counters. PWM unit

    (six outputs) and watchdog.- Low power real-time clock with independent power and

    dedicated 32 kHz clock input.

    - Multiple serial interfaces including two UARTs.

    Application Software

    Multitasking of LED, Serial Port, LCD and Keyboard.

  • 7/29/2019 ppt on moving msg display

    10/42

    Design of the System Flow

    BeginDevelopment

    PortApplication

    Port RTOS,

    COS-IIResearch on

    RTOS, COS-II

    Configure

    Compiler

    Research on

    Compiler

    Research on

    Application

    Configure

    Hardware

    Integrate

    Components

    and download

    Hex file

    Testing

    Fig.3. Design Flow

  • 7/29/2019 ppt on moving msg display

    11/42

    System Design

    RTOSScheduler :

    The scheduler, also called as dispatcher, is the part of the

    kernel which is responsible for determining which task will

    run next and when.

    Most real-time kernels are priority based; each task is

    assigned a priority based on its importance.

    Establishing the priority for each task is applicationspecific.

    In a priority based kernel, control of the CPU will always

    be given to the highest priority task ready to run.

  • 7/29/2019 ppt on moving msg display

    12/42

    When the highest priority task gets the CPU, however,

    it depends on the type ofscheduler used.

    There are two types of schedulers:

    non-preemptiveand preemptive.

    Non-preemptive scheduling :

    is also called cooperative multitasking.

    An ISR can make a higher priority task ready to run but

    the ISR always return to the interrupted task.

  • 7/29/2019 ppt on moving msg display

    13/42

    The new higher priority task will gain control of the

    CPU only when the current task voluntarily gives up the

    CPU.

    Low priority task

    ISRISR makes

    high

    priority

    task ready

    High priority task

    Low priority task

    Relinquishes cpu

    Fig.4. Non Preemptive scheduling

  • 7/29/2019 ppt on moving msg display

    14/42

    Preemptive scheduling :Low priority task

    ISR

    ISR makes high

    priority task ready

    High priority task

    relinquishes cpu

    High

    priority

    task

    Fig.5. Preemptive scheduling

  • 7/29/2019 ppt on moving msg display

    15/42

    when an event makes a higher priority task readyto run, the current task is immediately suspendedand the higher priority task is given control of theCPU.

    Most real-time systems employ preemptiveschedulers because they are more responsive.

    RTOS,COS-II is chosen here because it haspreemptive scheduler.

    And also has many more features:Source code: is available free for non commercial

    use and is well documented that it describes how

    it works.

  • 7/29/2019 ppt on moving msg display

    16/42

    Portable: is written in highly portable ANSI C. Target

    processor code is in assembly language, purposely kept

    minimum to make it easy to port on any processor.

    ROMable: designed for embedded applications. if we

    have proper tool chain (i.e. C compiler, assembler and

    linker/locator) then we can embed it as a part of product.

    Scalable: We can use only the services that we need inour application. This allows us to reduce the amount of

    memory (both RAM and ROM) needed by C/OS-II.

    Scalability is accomplished with the use of conditional

    compilation. You simply specify (through #defineconstants) which features you need for your application.

  • 7/29/2019 ppt on moving msg display

    17/42

    Preemptive: is a fully-preemptive real-time kernel. This

    means that C/OS-II always runs the highest priority task

    that is ready.

    Multi-tasking: can manage up to 64 tasks, however, thecurrent version of the software reserves eight (8) of these

    tasks for system use.56 tasks leaves for application. There

    are thus 64 priority levels.

    Deterministic: Execution time of all C/OS-II functions and

    services are deterministic.

    Task stacks: Each task requires its own stack, however,

    C/OS-II allows each task to have a different stack size.This allows you to reduce the amount of RAM needed in

    your application.

    S i id b f i h

  • 7/29/2019 ppt on moving msg display

    18/42

    Services: provides a number of system services suchas mailboxes, queues, semaphores, fixed-sizedmemory partitions, time related functions, etc.

    Interrupt Management: Interrupts can suspend theexecution of a task and, if a higher priority task isawakened as a result of the interrupt, the

    highest priority task will run as soon as all nestedinterrupts complete. Interrupts can be nested up to255 levels deep.

    Robust and reliable: C/OS-II is based on C/OS

    which has been used in hundreds of commercialapplications since 1992 and uses the same core andmost of the same functions as C/OS yet offers

    more features.

  • 7/29/2019 ppt on moving msg display

    19/42

    Port RTOS, COS-II:

    Adapting RTOS to any processor is known as RTOS

    porting.Application Software

    COS-II(Processor Independent Code)

    os_core.c,os_flag.c,

    os_mbox.c,os_mutex.c,

    os_q.c,os_sem.cos_task.c,os_time.c,

    ucos-ii.c,ucos-ii.h

    TimerCPU

    COS-II Conf.(Application Specific Code)

    os_cfg.h

    includes.h

    COS-II Port(Processor Specific Code)

    os_cpu.h

    os_cpu_c.cos_cpu_a.S

    Software

    ---------------------------------------------------------------------------------------

    Hardware

    Fig.6. COS-II, Hardware/Software Architecture

  • 7/29/2019 ppt on moving msg display

    20/42

    Fig. shows, COS-II file structure.

    Kernel code is organized in three segments.

    Application Specific Code: Contains user specific application software as well as some

    code related to COS-II.

    This includes initializing and starting the kernel and kernel

    specific code for task management, synchronization andcommunication.

    Processor Independent Code:

    Is main code of COS-II. Is independent of actual target processor.

    It provides kernel services for task management, timemanagement, semaphores, scheduling policy and memory

    management.

  • 7/29/2019 ppt on moving msg display

    21/42

    Processor Specific Code:

    Contains an adaptation layer: port to the selected

    target processor. This code typically manipulates directly individual

    processor registers. e.g. In order to switch context.

  • 7/29/2019 ppt on moving msg display

    22/42

    For porting RTOS, COS-II:

    Application Specific Code:

    includes.h:

    -is a master file, found at the top of all .c files.-it allows every .c file in the project to be written

    without concerns about which header file actually

    needed./*MASTER INCLUDE FILE*/

    #include

    #include

    #include

    #include #include

    #include

    #include

    #include "lpc21xx.h"

  • 7/29/2019 ppt on moving msg display

    23/42

    os_cfg.h:

    -is COS-II Configuration File.

    -Using this file we simply specify (through #define

    constants) which feature we need in our application.

    /* COS-II Configuration File*/

    #ifndef OS_CFG_H

    #define OS_CFG_H

    /* TASK MANAGEMENT */

    #define OS_TASK_CHANGE_PRIO_EN 1 /* Include code for OSTaskChangePrio() */

    #define OS_TASK_CREATE_EN 1 /* Include code for OSTaskCreate() */

    #define OS_TASK_CREATE_EXT_EN 1 /* Include code for OSTaskCreateExt() */

    #define OS_TASK_DEL_EN 1 /* Include code for OSTaskDel() */

    #define OS_TASK_NAME_SIZE 32 /* Determine the size of a task name */

    #define OS_TASK_PROFILE_EN 1 /* Include variables in OS_TCB for profiling */

    #define OS_TASK_QUERY_EN 1 /* Include code for OSTaskQuery() */#define OS_TASK_SUSPEND_EN 1 /* Include code for OSTaskSuspend() and

    OSTaskResume() */

    #define OS_TASK_SW_HOOK_EN 1 /* Include code for OSTaskSwHook() */

  • 7/29/2019 ppt on moving msg display

    24/42

    /* TIME MANAGEMENT */#define OS_TIME_DLY_HMSM_EN 1 /* Include code for OSTimeDlyHMSM() */

    #define OS_TIME_DLY_RESUME_EN 0 /* Include code for OSTimeDlyResume() */

    #define OS_TIME_GET_SET_EN 1 /* Include code for OSTimeGet() and

    OSTimeSet() */

    #define OS_TIME_TICK_HOOK_EN 1 /* Include code for OSTimeTickHook() */

    #endif

  • 7/29/2019 ppt on moving msg display

    25/42

    Processor Specific Code:

    os_cpu.h:

    OS_CPU.H contains processor andimplementation specific #defines constants,

    macros, and typedefs.

    os_cpu_a.asm:

    A C/OS-II port requires that need to write four

    assembly language functions:

    OSStartHighRdy (), OSCtxSw (), OSIntCtxSw (),OSTickISR ()

    OSStartHighRdy (): This is used to start multitasking.

    This function is called by OSStart () to start the

    highest priority task ready-to-run.

    OSCtxSw():

  • 7/29/2019 ppt on moving msg display

    26/42

    OSCtxSw():

    This is used for task level context switch.

    This function is executed when an interrupt is

    encountered.C/OS-II causes a higher priority task to be ready-to-run.

    The job of OSCtxSw() is to save the current taskcontext, switch over to higher priority task and then

    restore context.The code saves current tasks registers onto its stack;

    content of the link register is saved to both the linkregister and the program counter locations on the

    stack.The task stack pointer is then saved to its task control

    block, OSTaskSwHook() function is called, the higherpriority task stack is loaded, and the context of higher

    priority task is restored.

    OSIntCtxSw():

  • 7/29/2019 ppt on moving msg display

    27/42

    OSIntCtxSw():

    This is used for interrupt level context switch.

    This function is called by OSIntExit() to perform a

    context switch from an ISR, it is assumed that all theprocessor registers are already properly saved onto

    the interrupted tasks stack.

    The interrupt level context switch code is similar to thetask level context switch, except that the ISR has

    already done the work of saving the processor context

    the task stack.

    OSTickISR ():C/OS-II requires that you should provide a periodic

    time source to keep track on time delays and timeouts.

    os cpu c c:

  • 7/29/2019 ppt on moving msg display

    28/42

    os_cpu_c.c:

    COS-II port requires that you write six fairly simple C

    functions: OSTaskStkInit(), OSTaskCreateHook(),

    OSTaskDelHook(), OSTaskSwHook(),OSTaskStatHook(), OSTimeTickHook().

    The only function that is actually necessary is

    OSTaskStkInit(). The other five functions must be

    declared but theres no need to contain any code

    inside them. OSTaskStkInit() function is called by

    OSTaskCreate() and OSTaskCreateExt() to initialize

    the stack frame of a task.

    Processor Independent Code

  • 7/29/2019 ppt on moving msg display

    29/42

    Processor Independent Code

    As per the earlier discussion, processorindependent code is the main code of COS-II.

    This code is independent of actual targetprocessor. Thus, this code need not to be changed;only it is required to be include in the project.

    It provides kernel services for task management,

    time management, semaphores, scheduling policyand memory management

  • 7/29/2019 ppt on moving msg display

    30/42

    For Porting Application:

    Application Software

    -it consists multitasking of three tasks

    Task 1: LED ON/OFF.

    Task 2: Print Character through Serial Port.

    Task3: Display key code on LCD display.

    -Each task is created with following function.

    OSTaskCreate (void (*task)(void *pd), void *pdata,

    OS_STK *ptos, INT8U prio)

  • 7/29/2019 ppt on moving msg display

    31/42

    OSTaskCreate() requires four arguments.

    taskis a pointer to the task code,

    pdata is a pointer to an argument that will be passed to yourtask

    when it starts executing, ptos is a pointer to the top of the

    stack that will be assigned to the task(Task Stacks) and

    finally, prio is the desired task priority.

    For Example:

    OS_STK Task1Stk[1024];

    OSTaskCreate(App_Task1,(void*)0,&Task1Stk[1023],6);

    D l ti d d fi iti f T k

  • 7/29/2019 ppt on moving msg display

    32/42

    Declaration and definition of Task:

    -Every task must be written as infinite loop

    void App_Task1 (void *pdata); /* Declaration of Task */

    void App_Task1 (void *pdata) /* Task Definition */

    {

    (void)pdata;

    IO0DIR |= 0x00004000 ; /* IO Direction as Output*/

    while(1)

    {

    IO0CLR = (1

  • 7/29/2019 ppt on moving msg display

    33/42

    Delaying a task, OSTimeDlyHMSM()

    We can specify time in hours (H), minutes (M),seconds (S) and milliseconds (M) which is morenatural.

    Calling this function causes a context switch andforces C/OS-II to execute the next highest

    priority task that is ready-to-run. The task callingOSTimeDlyHMSM() will be made ready-to-runas soon as the time specified expires.

    This is the way there is context switch betweenall three tasks and multitasking is observed for allthree tasks.

  • 7/29/2019 ppt on moving msg display

    34/42

    Compilation and Downloading procedure:

    All required files from application specific code,processor specific code, processor independent code

    and application software code are copied on singlefolder.

    New project is created using the ARM specific crosscompiler (SCARM-IDE).

    The makefile is edited for writing path of the folderthat is working directory. Then makefile is linked withthe project in the compiler (SCARM-IDE) with projectsetting option.

    Then the code is compiled using build project option,this will generate hex file of project.

    This hex file is downloaded on ARM7 LPC2148Board through Flash magic utility

  • 7/29/2019 ppt on moving msg display

    35/42

    Fig.7. Downloading the Hex file on LPC 2148 Processor

    E i t l S t

  • 7/29/2019 ppt on moving msg display

    36/42

    ExperimentalSetup:

    Power Supply

    Computer

    LCD Display

    Keyboard

    LPC2148

    Fig.8. Experimental Setup

    Results:

  • 7/29/2019 ppt on moving msg display

    37/42

    Results:

    1) LED becoming ON and OFF for 500ms.

    2)Output on Flash magic Terminal through serial portfor every 600ms.

    Fig.9. Output on Flash magic Terminal through serial port

  • 7/29/2019 ppt on moving msg display

    38/42

    3)Displays key code on LCD whenever user press key

    from (4X4) matrix keyboard.

    LCD Displays

    Key code Fig.10. LCD output

  • 7/29/2019 ppt on moving msg display

    39/42

    Conclusion:

    Thus the use of COS-II for multitasking, met timingcorrectness.

    Preemptive scheduler in COS-II makes the real time

    system more responsive.

    THUMB code provide up to 65% of the code size of

    ARM, and 160% of the performance of an equivalent

    ARM processor connected to a 16-bit memory system.

    Poorly designed and configured software architecturesmight even generate high response times while the

    physical resources display low utilization.

  • 7/29/2019 ppt on moving msg display

    40/42

    References:[1] V.Billy Rakesh Roy, Sanket Dessai, and S. G.Shiva Prasad Yadav, Design and

    Development of ARM Processor Based Web Server, International Journal of Recent

    Trends in Engineering, Vol. 1, No. 4, May 2009.

    [2] Jean J. Labrosse, MicroC/OS-II The real time kernel, R &D Publications,

    second edition, 1992.

    [3] http://www.uCOS-II.com

    [4] http://www.semiconductors.philips.com, http://www.arm.com, datasheet for

    LPC2148..

    [5] http://www.micrium.com, C/OS-II and The ARM Processor, Application Note,

    AN-1011 Rev. D.

    [6] Gunar Schirner, Gautam Sachdeva, Andreas gerstlauer, Rainer Domer,

    Modeling, Simulation and Synthesis in an Embedded software design flow for ARM

    processor, University of California, Irvine, Irvine, (A92697-3425, USA,

    http://www.cecs.uci.edu[7] D.W.Hawkins, ([email protected]), Real time processing with the Philips

    LPC ARM microcontroller using GCC and the MicroC/OS-II RTOS , Philips 05:

    Project Number AR1803.

    http://www.semiconductors.philips.com/http://www.arm.com/http://www.micrium.com/http://www.cecs.uci/mailto:[email protected]:[email protected]://www.cecs.uci/http://www.micrium.com/http://www.arm.com/http://www.semiconductors.philips.com/
  • 7/29/2019 ppt on moving msg display

    41/42

    Publications:1) S.D.Mali, Dr.A.D.Jadhav Porting RTOS on ARM and Implementation of ARM

    based Web Server, IEEE sponsored National Conference on Pervasive

    Computing2010, Sinhgad college of Engineering, Pune.

    2) S.D.Mali, Embedded Web Server using RTOS Porting on ARM Processor, 4th

    National Conference on Recent Trends in Communication, Electronics &

    Information Technology, CMRIT, Bangalore.

    3) S.D.Mali, Dr.A.D.Jadhav Porting RTOS on ARM and Implementation of ARMbased Web Server, ePGCON-2010, Rajashri College of Engineering, Thathwade,

    Pune & University of Pune.

  • 7/29/2019 ppt on moving msg display

    42/42

    THANK YOU