带有 SAM3X8EArduino DuexTaskCreate 的 FreeRTOS 10 未运行

问题描述

我通过 SAM 端口使用 Microchip Studio 7.0.2542 和 Atmel-ICE JTAG 调试器 - 所有这些都已连接并且可以单步执行程序。

尽管 xTimerCreate 返回 xTaskCreate,但通过 1 创建的计时器不会触发,我也无法进入 FreeRTOS 任务,而且 vTaskStartScheduler 保持在自己的循环中(正如预期的那样,我的程序永远不会结束)。

#include <asf.h>

// Prototypes for the standard FreeRTOS callback/hook functions implemented within this file.
void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask,char *pcTaskName );
void vApplicationTickHook( void );

static void prvLEDTimerCallback(void *pvParameters);

volatile int ran = 0;

// Task Handles.
// xTaskHandle worker1_id;

static void worker1_task(void *pvParameters)
{
    ran = 1;
    static uint32_t idelay;
    static uint32_t Delay;
    Delay = 100000;

    for(;;)
    {
        // Simulate work
        for (idelay = 0; idelay < Delay; ++idelay);     
    }
    // Should never reach here.
}

int main (void)
{
    volatile int taskCreateResult = -1;
    sysclk_init();  
    NVIC_SetPriorityGrouping(0); // Ensure all priority bits are assigned as preemption priority bits.
    board_init();

    xLEDTimer = xTimerCreate((const signed char * const) "LED timer",/* A text name,purely to help debugging. */
    (200 / portTICK_RATE_MS),/* The timer period. */
    pdTRUE,/* This is an auto-reload timer,so xAutoReload is set to pdTRUE. */
    NULL,/* The timer does not use its ID,so the ID is just set to NULL. */
    prvLEDTimerCallback         /* The function that is called each time the timer expires. */
    );

    xTimerStart(xLEDTimer,0);


    
    taskCreateResult = xTaskCreate(worker1_task,(const signed char * const) "worker1",configMINIMAL_STACK_SIZE*2,NULL,1,NULL);
    vTaskStartScheduler();
    
    // The scheduler will now be running,and the following line should never be reached.
    while(1);
}

static void prvLEDTimerCallback(void *pvParameters)
{
    int i = 0;
}

void vApplicationMallocFailedHook( void )
{
    taskDISABLE_INTERRUPTS();
    for( ;; );
}

void vApplicationIdleHook( void )
{
}

void vApplicationStackOverflowHook( TaskHandle_t pxTask,char *pcTaskName )
{
    ( void ) pcTaskName;
    ( void ) pxTask;

    taskDISABLE_INTERRUPTS();
    for( ;; );
}

void vApplicationTickHook( void )
{
}

问题请

注意:我创建了一个 File -> New -> Example Project -> FreeRTOS Peripheral Control Example - Arduino Due/X 并且项目运行并且我可以成功地中断任务。

我在初始化和任务创建方面的主循环似乎与演示相同,但​​演示还可以,而我的不行。

请问我做错了什么,或者进一步调试为什么我的任务没有运行的指针?我已经展示了我是如何创建项目的,并在此问题的末尾包含了默认/未修改的 FreeRTOSConfig.h

我在构建示例时采取的步骤如下:

它是通过 File -> New -> Project -> GCC C ASF Board Project -> Select by Board = Arduino Due/X - ATSAM3X8E 创建的,并选择了扩展名 Atmel ASF 3.50.0

我确认我通过 ASF Board Wizard 选择了正确的开发板,然后通过 ASF Wizard 拉入 FreeRTOS 10 并添加 FreeRTOS mini Real-Time Kernel (service) 10.0.0 并点击应用。

所有源文件都在 Solution -> src -> ASF 下导入,包括 freertos 文件。

然后我添加上面的代码,并使用下面的默认配置文件:

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H

/* For definition of BOARD_MCK. */
#ifndef __IAR_SYSTEMS_ASM__
    /* Prevent chip.h being included when this file is included from the IAR
    port layer assembly file. */
    #include "board.h"
#endif

#define configUSE_PREEMPTION                    1

#define configUSE_QUEUE_SETS                    1
#define configUSE_IDLE_HOOK                     0
#define configUSE_TICK_HOOK                     1
#define configCPU_CLOCK_HZ                      ( 8000000)
#define configTICK_RATE_HZ                      ( 1000 )
#define configMAX_PRIORITIES                    ( 5 )
#define configMINIMAL_STACK_SIZE                ( ( unsigned short ) 130 )
#define configTOTAL_HEAP_SIZE                   ( ( size_t ) ( 46 * 1024 ) )
#define configMAX_TASK_NAME_LEN                 ( 10 )
#define configUSE_TRACE_FACILITY                1
#define configUSE_16_BIT_TICKS                  0
#define configIDLE_SHOULD_YIELD                 1
#define configUSE_MUTEXES                       1
#define configQUEUE_REGISTRY_SIZE               8
#define configCHECK_FOR_STACK_OVERFLOW          2
#define configUSE_RECURSIVE_MUTEXES             1
#define configUSE_MALLOC_FAILED_HOOK            1
#define configUSE_APPLICATION_TASK_TAG          0
#define configUSE_COUNTING_SEMAPHORES           1

/* The full demo always has tasks to run so the tick will never be turned off.
The blinky demo will use the default tickless idle implementation to turn the
tick off. */
#define configUSE_TICKLESS_IDLE                 0

/* Run time stats gathering definitions. */
#define configGENERATE_RUN_TIME_STATS   0

/* This demo makes use of one or more example stats formatting functions.  These
format the raw data provided by the uxTaskGetSystemState() function in to human
readable ASCII form.  See the notes in the implementation of vTaskList() within
FreeRTOS/Source/tasks.c for limitations. */
#define configUSE_STATS_FORMATTING_FUNCTIONS    1

/* Co-routine definitions. */
#define configUSE_CO_ROUTINES           0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )

/* Software timer definitions. */
#define configUSE_TIMERS                1
#define configTIMER_TASK_PRIORITY       ( configMAX_PRIORITIES - 1 )
#define configTIMER_QUEUE_LENGTH        5
#define configTIMER_TASK_STACK_DEPTH    ( configMINIMAL_STACK_SIZE * 2 )

/* Set the following definitions to 1 to include the API function,or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet        1
#define INCLUDE_uxTaskPriorityGet       1
#define INCLUDE_vTaskDelete             1
#define INCLUDE_vTaskCleanUpResources   1
#define INCLUDE_vTaskSuspend            1
#define INCLUDE_vTaskDelayUntil         1
#define INCLUDE_vTaskDelay              1
#define INCLUDE_eTaskGetState           1
#define INCLUDE_xTimerPendFunctionCall  1

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
    /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
    #define configPRIO_BITS             __NVIC_PRIO_BITS
#else
    #define configPRIO_BITS             3        /* 7 priority levels */
#endif

/* The lowest interrupt priority that can be used in a call to a "set priority"
function. */
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY         0x07

/* The highest interrupt priority that can be used by any interrupt service
routine that makes calls to interrupt safe FreeRTOS API functions.  DO NOT CALL
INTERRUPT SAFE FREERTOS API FUNCTIONS FROM ANY INTERRUPT THAT HAS A HIGHER
PRIORITY THAN THIS! (higher priorities are lower numeric values. */
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY    4

/* Interrupt priorities used by the kernel port layer itself.  These are generic
to all Cortex-M ports,and do not rely on any particular library functions. */
#define configKERNEL_INTERRUPT_PRIORITY         ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )

/* Normal assert() semantics without relying on the provision of an assert.h
header file. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS
standard names.Based on the architecture  choosen,the below definitons may be needed*/

/*#define xPortPendSVHandler PendSV_Handler
#define vPortSVCHandler SVC_Handler
#define xPortSysTickHandler SysTick_Handler */

#endif /* FREERTOS_CONFIG_H */

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...