Using FreeRTOS, where is best place to initialize tasks?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MiRo_263836
Level 5
Level 5
100 replies posted 50 likes received 50 replies posted

This is the 1st time that I am using FreeRTOS in WICED (on an STM32F429) and I want to make sure that I am initializing tasks in the best place.  I did it right after wiced_init() in the application start. 

void application_start( )

{

    wiced_init( );

    TaskConfigID_handle = xTaskCreateStatic( TaskConfigID, "AssignID", CONFIG_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), ConfigIDStack, &ConfigID_buffer );

    TaskICM20948_handle = xTaskCreateStatic( TaskICM20948, "IMU", IMU_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), ICM20948Stack, &ICM20948_buffer );

    TaskBQ27411_handle  = xTaskCreateStatic( TaskBQ27411, "FuelGauge", BAT_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), BQ28411Stack, &BQ27411_buffer );

    TaskUI_handle       = xTaskCreateStatic( TaskUI, "UserLED", UI_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), UIStack, &UI_buffer );

    TaskSFlash_handle   = xTaskCreateStatic( TaskSFlash, "SFlash", SFLASH_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), SFlashStack, &SFlash_buffer );

    TaskDebug_handle    = xTaskCreateStatic( TaskDebug, "Debug", DEBUG_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), DebugStack, &Debug_buffer );

    TaskUSB_HS_handle   = xTaskCreateStatic( TaskUSB, "USB_HS",USB_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), USB_HS_Stack, &USB_HS_buffer );

    TaskWIFI_handle     = xTaskCreateStatic( TaskWIFI, "WIFI", WIFI_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), WIFIStack, &WIFI_buffer );

    TaskBlue_handle     = xTaskCreateStatic( TaskWIFI, "Blue", BLUE_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), BlueStack, &Blue_buffer );

    TaskRTC_handle      = xTaskCreateStatic( TaskWIFI, "RTC", RTC_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), RTCStack, &RTC_buffer );

    TaskOTA_handle      = xTaskCreateStatic( TaskWIFI, "OTA", OTA_TASK_STACK_SIZE, NULL, WICED_PRIORITY_TO_NATIVE_PRIORITY(WICED_APPLICATION_PRIORITY), OTAStack, &OTA_buffer );

0 Likes
1 Solution
Yeshwanth_KT
Employee
Employee
50 replies posted 25 replies posted 10 likes received

Hello mroberts_arrow

Yes, the correct place to initialize tasks is after wiced_init(). This will make sure that all the required peripherals are initialized before any thread starts.

You can also go through this RTOS tutorial series for more information and learning - https://www.cypress.com/training/wiced-wi-fi-101-chapter-3-wiced-rtos-features

Thanks,

Yeshwanth

View solution in original post

1 Reply
Yeshwanth_KT
Employee
Employee
50 replies posted 25 replies posted 10 likes received

Hello mroberts_arrow

Yes, the correct place to initialize tasks is after wiced_init(). This will make sure that all the required peripherals are initialized before any thread starts.

You can also go through this RTOS tutorial series for more information and learning - https://www.cypress.com/training/wiced-wi-fi-101-chapter-3-wiced-rtos-features

Thanks,

Yeshwanth