Download - Embedded OS

Transcript
  • Creating an Embedded Operating System

    2

    Super Loop Limitations

    | The super loop cannot be used to periodically execute a function at fixed intervals unless:zWe know the precise execution time

    for the functionz The execution time is fixed and never

    varies

    3

    Sample Situations with Periodic Timing Needs

    | A music sample must be converted every 20 ms.| The current speed of the vehicle must be measured at 0.5 second

    intervals.| The display must be refreshed 40 times every second.| The calculated new throttle setting must be applied every 0.5

    seconds.| A time-frequency transform must be performed 20 times every

    second.| The engine vibration data must be sampled 1000 times per second.| The frequency-domain data must be classified 20 times every

    second.| The keypad must be scanned every 200 ms.| The master (control) node must communicate with all other nodes

    (sensor nodes and sounder nodes) once per second.| The new throttle setting must be calculated every 0.5 seconds.| The sensors must be sampled once per second.

  • 4A Simple Embedded OS

    | Use a timer in conjunction with an interrupt to periodically run an interrupt service routine

    | The interrupt signal is often referred to as the system tick

    5

    Modified Super Loop

    void main(void){

    Timer_2_Init(); // Set up Timer 2EA = 1; // Globally enable interruptswhile(1); // An empty Super Loop

    }

    6

    Interrupt Sources

  • 7Automatic Timer Reloads

    | Timers 0 and 1 can be automatically reloaded in 8-bit mode

    | Timer 2 is automatically reloaded every time it overflows

    8

    Timer-driven vs. Event-driven

    | In a timer-driven system, the system relies on a fixed system tick to run tasks

    | In an event-driven system, the systems depends on external interrupts to run tasks

    Which is more reliable? Why?

    9

    Co-operative vs. pre-emptive Scheduling| A co-operative schedule lets tasks run

    to completion before switching to another task

    | A pre-emptive scheduler runs multiple tasks in a round-robin fashion

    Which is more reliable? Why?

  • 10

    Design Considerations

    | It is important that the total time of all tasks not exceed the system tick

    | It is prudent to not use any other interrupts in conjunction with the timer interrupt in order to avoid conflict between interrupt service routines

    11

    Measuring Flow

    12

    Embedded vs. Real-Time OS