13.12.2012 Views

emWin - SEGGER Microcontroller

emWin - SEGGER Microcontroller

emWin - SEGGER Microcontroller

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

314 CHAPTER Execution Model: Single Task / Multitask<br />

14.1 Supported execution models<br />

We have to basically distinguish between 3 different execution models:<br />

Single task system (superloop)<br />

The entire program runs in one superloop. Normally, all software components are<br />

periodically called. Interrupts must be used for real time parts of the software since<br />

no real time kernel is used.<br />

Multitask system: one task calling <strong>emWin</strong><br />

A real time kernel (RTOS) is used, but only one task calls <strong>emWin</strong> functions. From the<br />

graphic software’s point of view, it is the same as being used in a single task system.<br />

Multitask system: multiple tasks calling <strong>emWin</strong><br />

A real time kernel (RTOS) is used, and multiple tasks call <strong>emWin</strong> functions. This<br />

works without a problem as long as the software is made thread-safe, which is done<br />

by enabling multitask support in the configuration and adapting the kernel interface<br />

routines. For popular kernels, the kernel interface routines are readily available.<br />

14.2 Single task system (superloop)<br />

14.2.1 Description<br />

The entire program runs in one superloop. Normally, all components of the software<br />

are periodically called. No real time kernel is used, so interrupts must be used for<br />

real time parts of the software. This type of system is primarily used in smaller systems<br />

or if real time behavior is not critical.<br />

14.2.2 Superloop example (without <strong>emWin</strong>)<br />

void main (void) {<br />

HARDWARE_Init();<br />

}<br />

/* Init software components */<br />

XXX_Init();<br />

YYY_Init();<br />

/* Superloop: call all software components regularily */<br />

while (1) {<br />

/* Exec all compontents of the software */<br />

XXX_Exec();<br />

YYY_Exec();<br />

}<br />

14.2.3 Advantages<br />

No real time kernel is used (-> smaller ROM size, just one stack -> less RAM for<br />

stacks), no preemption/synchronization problems.<br />

14.2.4 Disadvantages<br />

The superloop type of program can become hard to maintain if it exceeds a certain<br />

program size. Real time behavior is poor, since one software component cannot be<br />

interrupted by any other component (only by interrupts). This means that the reaction<br />

time of one software component depends on the execution time of all other components<br />

in the system.<br />

14.2.5 Using <strong>emWin</strong><br />

There are no real restrictions regarding the use of <strong>emWin</strong>. As always, GUI_Init()<br />

has to be called before you can use the software. From there on, any API function<br />

can be used. If the Window Manager’s callback mechanism is used, then an <strong>emWin</strong><br />

update function has to be called regularly. This is typically done by calling the<br />

UM03001 User & Reference Guide for <strong>emWin</strong> V5.18 © 1997 - 2012 <strong>SEGGER</strong> <strong>Microcontroller</strong> GmbH & Co. KG

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!