Skip to content

Commit 84725b3

Browse files
committed
Extended info in BasicMultiThreading
1 parent c18d355 commit 84725b3

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

libraries/MultiThreading/examples/BasicMultiThreading/BasicMultiThreading.ino

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,23 @@
1717
During that delay any other task may run and do it's job.
1818
When the delay runs out the Operating System gives the processor to the task which can continue.
1919
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
2037
*/
2138

2239
#if CONFIG_FREERTOS_UNICORE
@@ -43,17 +60,17 @@ void setup() {
4360
uint32_t blink_delay = 1000; // Delay between changing state on LED pin
4461
xTaskCreate(
4562
TaskBlink
46-
, "TaskBlink" // A name just for humans
63+
, "Task Blink" // A name just for humans
4764
, 1024 // The stack size can be checked by calling `uxHighWaterMark = uxTaskGetStackHighWaterMark(NULL);`
4865
, (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
5168
);
5269

5370
// This variant of task creation can also for the task to run specified core
5471
xTaskCreatePinnedToCore(
5572
TaskAnalogReadA3
56-
, "AnalogReadA3"
73+
, "Analog Read A3"
5774
, 1024 // Stack size
5875
, NULL // When no parameter is used, simply pass NULL
5976
, 1 // Priority

0 commit comments

Comments
 (0)