Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

TaskCreate is not working in my project

Posted by barry0808 on January 23, 2019

Hi, I created two task as below , but only MainTask1 been invoking , do I missing something ?

xReturn = xTaskCreate( MainTask1,
             "MainTask1", 
             configMINIMAL_STACK_SIZE, 
             ( void * ) NULL, 
             1, 
             &xHandle1 );

xReturn = xTaskCreate( MainTask2,
             "MainTask2", 
             configMINIMAL_STACK_SIZE, 
             ( void * ) NULL, 
             1, 
             &xHandle2 );

vTaskStartScheduler();


TaskCreate is not working in my project

Posted by rtel on January 23, 2019

What is the value of xReturn after the second call to xTaskCreate()? Maybe you just ran out of heap. Do you have a malloc failed hook defined?


TaskCreate is not working in my project

Posted by richarddamon on January 23, 2019

A second possiblility would be does MainTask1 ever block to leave time for MainTask2 to execute?


TaskCreate is not working in my project

Posted by barry0808 on January 23, 2019

thanks Richard, you second idea is the case. I change as below , I can see two tasks get executed. However , I expected they get executed in turn but they are only get executed once. and system stuck at "prvCheckTasksWaitingTermination" function. any idea ?

void MainTask1( void *pvParameters ) { TickType_t xNextWakeTime;

xNextWakeTime = xTaskGetTickCount();

for( ;; ){

    TRACE0(182, RTOS, 0, "Task1 loop");
	vTaskDelayUntil( &xNextWakeTime,  200 / portTICK_PERIOD_MS );
}

}

void MainTask2( void *pvParameters ) { TickType_t xNextWakeTime;

xNextWakeTime = xTaskGetTickCount();

for( ;; ){

    TRACE0(182, RTOS, 0, "Task2 loop");
	vTaskDelayUntil( &xNextWakeTime,  200 / portTICK_PERIOD_MS );
}

}


TaskCreate is not working in my project

Posted by richarddamon on January 24, 2019

Make sure the tick interrupt is running. That function is called in the idle task, which runs when no other task is ready. The Idle task checks to see if it needs to do any cleanup, does it then checks again, (and so on).


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.0 is available for immediate download. MIT licensed, and including RISC-V and ARMv8-M (Cortex-M33) demos.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Mediatek

Renesas

RISC-V

SiFIve RISC-V

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner