44/317
2 - How does a typical microcontroller work?
02-task
Common parts
of the program
Code of the
first task
Code of the
second task
Code of the
last task
Interrupt vector
table
Program memory
Stack RAM
Stack area
for task #1
Stack area
for task #2
Stack area
for the last task
2
3
1
4
Stack
pointer
1
2
3
4
Selection of the task
: The stack pointer points to
the last data of the task to activate that is stored
in the stack.
Activation of the task
: The popping of the data off
the stack restores the tasks as it was before being
unselected.
Deselection of the current task
: The state of the pro-
gram is saved in the stack before it is deselected.
Selection of the following task
: The stack pointer
points to the last data saved from the next tasks
to activate.
Working mechanism of a simplified multitasking kernel