Re Real-Ti Time Operating Systems (R (RTOS)
Chaipo Chaiporn J n Jaik aikae aeo De Department of f Computer Engineering Kasetsart Unive versity
01204322 Embedded System
Revised 2020-02-16
Materials partially taken from Lecture Slides by Prof. King
Re Real-Ti Time Operating Systems (R (RTOS) 01204322 Embedded - - PowerPoint PPT Presentation
Re Real-Ti Time Operating Systems (R (RTOS) 01204322 Embedded System Chaipo Chaiporn J n Jaik aikae aeo Department of De f Computer Engineering Kasetsart Unive versity Revised 2020-02-16 Materials partially taken from Lecture Slides
Revised 2020-02-16
Materials partially taken from Lecture Slides by Prof. King
2
3
User Application Operating System Hardware
4
User Operating System + Application Hardware
5
User Operating System + Application Hardware User Application Operating System Hardware Application Application Desktop OS Applications are compiled separately from the OS Embedded OS Application is compiled and linked together with the OS
6
Application
devices out of OS to application tasks kernel
Kernel Middleware Device driver Device driver Middleware Middleware Kernel Application Middleware Device driver Device driver Middleware Hardware Hardware Embedded OS Standard OS
7
8
IEEE Computer, 21(10), October 1988.
9
https://www.digikey.com/en/maker/projects/getting-started-with-stm32-introduction-to-freertos/ad275395687e4d85935351e16ec575b1
General-Purpose OS Real-Time OS
10
Background processing Sensor event handler
sensor event timer event
Timer event handler
11
12
13
resource management
14
to kernel
Running Blocked Ready Inactive
preempt schedule wait event terminate create terminate create terminate
Running Blocked Ready Inactive
yield schedule wait event terminate create terminate create terminate
15
Stack (for main app and IRQs) Free memory Heap for RTOS Heap (for main app) Data memory Task A Task B Queue Stack of Task A Task Control Block (TCB) end start
16
https://developer.arm.com/tools-and-software/embedded/cmsis
17
18
19
20
21
developers
22
23
https://os.mbed.com/docs/mbed-os/v5.15/apis/rtos.html
24
https://www.keil.com/pack/doc/CMSIS/RTOS2/html/theory_of_operation.html configured to the lowest priority
26
27
28
29
30
31
32
33
34
#include "mbed.h" void task_heartbeat() { DigitalOut led3(PB_3); while (1) { led3 = 1; wait(0.1); led3 = 0; wait(0.9); } } int main() { printf("Program started...\n"); task_heartbeat(); }
35
36
button or unplug/replug the board
37
set baud rate to 9600
results in the terminal
void task_countsw() { DigitalIn sw(PB_0, PullUp); uint32_t count = 0; while (1) { while (sw) // wait until switch is pressed ; wait(0.02); // simple debounce count++; printf("Switch pressed %d times\n", count); while (!sw) // wait until switch is released ; wait(0.02); // simple debounce } } int main() { printf("Program started...\n"); task_heartbeat(); task_countsw(); }
38
int main() { Thread t1, t2; printf("Program started...\n"); t1.start(callback(task_heartbeat)); t2.start(callback(task_countsw)); wait(osWaitForever); }
39