From 020d8170d4672036b70a47eea47114717c47ce8e Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 22 Sep 2008 13:43:07 +0000 Subject: [PATCH] Improve example code for xTaskCreate(). git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@478 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/include/task.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/include/task.h b/Source/include/task.h index 60193cfb7..54e7e3c3e 100644 --- a/Source/include/task.h +++ b/Source/include/task.h @@ -215,10 +215,13 @@ typedef struct xTIME_OUT // Function that creates a task. void vOtherFunction( void ) { - unsigned char ucParameterToPass; + static unsigned char ucParameterToPass; xTaskHandle xHandle; - // Create the task, storing the handle. + // Create the task, storing the handle. Note that the passed parameter ucParameterToPass + // must exist for the lifetime of the task, so in this case is declared static. If it was just an + // an automatic stack variable it might no longer exist, or at least have been corrupted, by the time + // the new time attempts to access it. xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle ); // Use the handle to delete the task. -- 2.39.2