新手上路
- 积分
- 31
- 金钱
- 31
- 注册时间
- 2017-7-29
- 在线时间
- 8 小时
|
1金钱
源码如下:麻烦各位大神帮忙看下是什么原因导致,谢谢。
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "FreeRTOS.h"
#include "task.h"
//任务优先级
#define START_TASK_PRIO 1
//任务堆栈大小
#define START_STK_SIZE 128
//任务句柄
TaskHandle_t StartTask_Handler;
//任务函数
void start_task(void *pvParameters);
//任务优先级
#define LED0_TASK_PRIO 2
//任务堆栈大小
#define LED0_STK_SIZE 128//50
//任务句柄
TaskHandle_t LED0Task_Handler;
//任务函数
void led0_task(void *pvParameters);
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);//设置系统中断优先级分组4
delay_init(); //延时函数初始化
LED_Init(); //初始化与LED连接的硬件接口
//创建开始任务
xTaskCreate((TaskFunction_t )start_task, //任务函数
(const char* )"start_task", //任务名称
(unsigned int )START_STK_SIZE, //任务堆栈大小
(void* )NULL, //传递给任务函数的参数
(UBaseType_t )START_TASK_PRIO, //任务优先级
(TaskHandle_t* )&StartTask_Handler); //任务句柄
vTaskStartScheduler(); //开启任务调度
// while(1);
}
//开始任务任务函数
void start_task(void *pvParameters)
{
taskENTER_CRITICAL(); //进入临界区
//创建LED0任务
xTaskCreate((TaskFunction_t )led0_task,
(const char* )"led0_task",
(uint16_t )LED0_STK_SIZE,
(void* )NULL,
(UBaseType_t )LED0_TASK_PRIO,
(TaskHandle_t* )&LED0Task_Handler);
vTaskDelete(StartTask_Handler); //删除开始任务
taskEXIT_CRITICAL(); //退出临界区
}
//LED0任务函数
void led0_task(void *pvParameters)
{
while(1)
{
// GPIO_ResetBits(GPIOA,GPIO_Pin_8); //LED0输出低
GPIO_SetBits(GPIOB,GPIO_Pin_15);//LED1输出高
delay_ms(300);
// GPIO_SetBits(GPIOA,GPIO_Pin_8);//LED0输出高
GPIO_ResetBits(GPIOB,GPIO_Pin_15);//LED1输出低
delay_ms(3000);
}
}
FreeRTOSConfig.h源码如下:
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
#include "sys.h"
#include "usart.h"
//?????????????stdint.h??
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
extern uint32_t SystemCoreClock;
#endif
//??
#define vAssertCalled(char,int) printf("Error:%s,%d\r\n",char,int)
#define configASSERT(x) if((x)==0) vAssertCalled(__FILE__,__LINE__)
/***************************************************************************************************************/
/* FreeRTOS???????? */
/***************************************************************************************************************/
#define configUSE_PREEMPTION 1 //1???????,0????
#define configUSE_TIME_SLICING 1 //1???????(??????)
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 //1??????????????????
//????????????,??????
//MCU?????????????????0!
#define configUSE_TICKLESS_IDLE 0 //1?????tickless??
#define configUSE_QUEUE_SETS 1 //?1?????
#define configCPU_CLOCK_HZ (SystemCoreClock) //CPU??
#define configTICK_RATE_HZ (200) //??????,?????1000,????1ms
#define configMAX_PRIORITIES (32) //?????????
#define configMINIMAL_STACK_SIZE ((unsigned short)130) //???????????
#define configMAX_TASK_NAME_LEN (16) //?????????
#define configUSE_16_BIT_TICKS 0 //?????????????,
//1???16??????,0???32??????
#define configIDLE_SHOULD_YIELD 1 //?1???????CPU???????????????
#define configUSE_TASK_NOTIFICATIONS 1 //?1?????????,????
#define configUSE_MUTEXES 1 //?1????????
#define configQUEUE_REGISTRY_SIZE 8 //??0?????????,???????
//??????????????
#define configCHECK_FOR_STACK_OVERFLOW 0 //??0???????????,???????
//???????????????,??????
//?????1??2,?????????????
#define configUSE_RECURSIVE_MUTEXES 1 //?1??????????
#define configUSE_MALLOC_FAILED_HOOK 0 //1????????????
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1 //?1????????
/***************************************************************************************************************/
/* FreeRTOS??????????? */
/***************************************************************************************************************/
#define configSUPPORT_DYNAMIC_ALLOCATION 1 //????????
#define configTOTAL_HEAP_SIZE ((size_t)(20*1024)) //?????????
/***************************************************************************************************************/
/* FreeRTOS???????????? */
/***************************************************************************************************************/
#define configUSE_IDLE_HOOK 0 //1,??????;0,???
#define configUSE_TICK_HOOK 0 //1,???????;0,???
/***************************************************************************************************************/
/* FreeRTOS??????????????????? */
/***************************************************************************************************************/
#define configGENERATE_RUN_TIME_STATS 0 //?1???????????
#define configUSE_TRACE_FACILITY 1 //?1?????????
#define configUSE_STATS_FORMATTING_FUNCTIONS 1 //??configUSE_TRACE_FACILITY???1??????3???
//prvWriteNameToBuffer(),vTaskList(),
//vTaskGetRunTimeStats()
/***************************************************************************************************************/
/* FreeRTOS?????????? */
/***************************************************************************************************************/
#define configUSE_CO_ROUTINES 0 //?1?????,????????????croutine.c
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) //??????????
/***************************************************************************************************************/
/* FreeRTOS????????????? */
/***************************************************************************************************************/
#define configUSE_TIMERS 1 //?1????????
#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES-1) //????????
#define configTIMER_QUEUE_LENGTH 5 //?????????
#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE*2) //???????????
/***************************************************************************************************************/
/* FreeRTOS???????? */
/***************************************************************************************************************/
#define INCLUDE_xTaskGetSchedulerState 1
#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
/***************************************************************************************************************/
/* FreeRTOS?????????? */
/***************************************************************************************************************/
#ifdef __NVIC_PRIO_BITS
#define configPRIO_BITS __NVIC_PRIO_BITS
#else
#define configPRIO_BITS 4
#endif
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 15 //???????
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 //?????????????
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
/***************************************************************************************************************/
/* FreeRTOS?????????????? */
/***************************************************************************************************************/
#define xPortPendSVHandler PendSV_Handler
#define vPortSVCHandler SVC_Handler
#endif /* FREERTOS_CONFIG_H */
|
|