微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > FreeRTOS只能创建2个任务?

FreeRTOS只能创建2个任务?

时间:10-02 整理:3721RD 点击:
为什么我的FreeRTOS只能创建两个任务,超出的就创建不成功?
static const char *task1name = "Task 1 is running\r";
static const char *task2name = "Task 2 is running\r";
static const char *task3name = "Task 3 is running\r";
void vTaskFunction(void *pvPara)
{
        char *pcTaskname;
        
        pcTaskname =  (char *)pvPara;
        while(1)
        {
                TCPApp_UartTx(pcTaskname,strlen(pcTaskname));
                vTaskDelay(1000);
        }
}
int main(void)
{
        /*!< At this stage the microcontroller clock setting is already configured to
       120 MHz, this is done through SystemInit() function which is called from
       startup file (startup_stm32f2xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f2xx.c file
     */
        System_Setup();
   
        /* Initilaize the LwIP stack */
////        LwIP_Init();
         
        /*start the comm serial task*/
        vAltStartComTestTasks( COM_TEST_PRIO, 115200 );
        /* Initialize tcp echo server */
//        tcpecho_init();
        
        #ifdef USE_DHCP
                /* Start DHCPClient */
                xTaskCreate(LwIP_DHCP_task, "DHCPClient", configMINIMAL_STACK_SIZE * 2, NULL,DHCP_TASK_PRIO, NULL);
        #endif
//                xTaskCreate(tcpclient_task, "client", configMINIMAL_STACK_SIZE, NULL, LED_TASK_PRIO, NULL);
        xTaskCreate(vTaskFunction, "task1", 1000, (void *)task1name, 2, NULL);
        xTaskCreate(vTaskFunction, "task2", 1000, (void *)task2name, 2, NULL);
        xTaskCreate(vTaskFunction, "task3", 1000, (void *)task3name, 1, NULL);
        /* Start scheduler */
        vTaskStartScheduler();
        /* We should never get here as control is now taken by the scheduler */
        while(1);
}
串口只能按顺序打印出
Task 2 is running
Task 1 is running
Task 2 is running
Task 1 is running

Task 2 is running
Task 1 is running

栈长度不够

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top