You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libraries/MultiThreading/examples/BasicMultiThreading/BasicMultiThreading.ino
+21-4Lines changed: 21 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,23 @@
17
17
During that delay any other task may run and do it's job.
18
18
When the delay runs out the Operating System gives the processor to the task which can continue.
19
19
For other ways to yield the CPU in task please see other examples in this folder.
20
+
21
+
Task creation has few parameter you should understand:
22
+
xTaskCreate(TaskFunction_t pxTaskCode,
23
+
const char * const pcName,
24
+
const uint16_t usStackDepth,
25
+
void * const pvParameters,
26
+
UBaseType_t uxPriority,
27
+
TaskHandle_t * const pxCreatedTask )
28
+
29
+
- pxTaskCode is the name of your function which will run as a task
30
+
- pcName is a string of human readable description for your task
31
+
- usStackDepth is number of words (word = 4B) available to the task. If you see error similar to this "Debug exception reason: Stack canary watchpoint triggered (Task Blink)" you should increase it
32
+
- pvParameters is a parameter which will be passed to the task function - it must be explicitly converted to (void*) and in your function explicitly converted back to the intended data type.
33
+
- uxPriority is number from 0 to configMAX_PRIORITIES which determines how the FreeRTOS will allow the tasks to run. 0 is lowest priority.
34
+
- pxCreatedTask task handle is basically a pointer to the task which allows you to manipulate with the task - delete it, suspend and resume.
35
+
If you don't need to do anything special with you task, simply pass NULL for this parameter.
36
+
You can read more about task control here: https://www.freertos.org/a00112.html
20
37
*/
21
38
22
39
#if CONFIG_FREERTOS_UNICORE
@@ -43,17 +60,17 @@ void setup() {
43
60
uint32_t blink_delay = 1000; // Delay between changing state on LED pin
44
61
xTaskCreate(
45
62
TaskBlink
46
-
, "TaskBlink"// A name just for humans
63
+
, "Task Blink"// A name just for humans
47
64
, 1024// The stack size can be checked by calling `uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL);`
48
65
, (void*) &blink_delay // Task parameter which can modify the task behavior. This must be passed as pointer to void.
49
-
, 2// Priority, with 3 (configMAX_PRIORITIES - 1) being the highest, and 0 being the lowest.
50
-
, NULL// Task handle is not used here
66
+
, 2// Priority
67
+
, NULL// Task handle is not used here - simply pass NULL
51
68
);
52
69
53
70
// This variant of task creation can also for the task to run specified core
54
71
xTaskCreatePinnedToCore(
55
72
TaskAnalogReadA3
56
-
, "AnalogReadA3"
73
+
, "Analog Read A3"
57
74
, 1024// Stack size
58
75
, NULL// When no parameter is used, simply pass NULL
0 commit comments