[求助] freertos里vTaskDelay不起作用

chenbingjy   2024-11-17 21:53 楼主

代码:

#include <avr/io.h>
#include <util/delay.h>

#include "FreeRTOS.h"
#include "task.h"
#include "LEDBlinkV1.h"





void LedOnTask( void *pvParameters )   // Task -1
{
	
	
	for( ;; )
	{
		LED_ON;_delay_ms(1000);
		taskYIELD();
		//vTaskDelayUntil(&OnLastWakeTime,OnFrequency);
	}
	
}

void LedOffTask( void *pvParameters )  //Task-2
{
	
	portTickType xLastWakeTime;
	for( ;; )
	{
		LED_OFF;
		//_delay_ms(1000);
		//vTaskDelayUntil(&xLastWakeTime,1000);
		vTaskDelay(1000);
		taskYIELD();
		
		//vTaskDelayUntil(&OffLastWakeTime,OffFrequency);
	}
	vTaskDelete(NULL);
}

portSHORT main(void)
{
	vCPU_Port_Init();
	
	xTaskCreate( LedOnTask, ( signed char * ) "LON", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); //Task creation for task-1
	xTaskCreate( LedOffTask, ( signed char * ) "LOFF", configMINIMAL_STACK_SIZE, NULL,2, NULL );//Task creation for task-2
	
	vTaskStartScheduler();//start scheduler
	//you should never get here
	while(1)
	{
		
	}
	return 0;
}

FreeRTOSconfig里

#define INCLUDE_vTaskPrioritySet		0
#define INCLUDE_uxTaskPriorityGet		0
#define INCLUDE_vTaskDelete				1
#define INCLUDE_vTaskCleanUpResources	0
#define INCLUDE_vTaskSuspend			0
#define INCLUDE_vTaskDelayUntil			1
#define INCLUDE_vTaskDelay				1

用_delay_ms()就好使,用vTaskDelay就不行。我用的atmega128

请问高手,如何解决?谢谢

为江山踏坏了乌骓马,为社稷拉断了宝雕弓。

回复评论 (1)

这是怎么测试出来不起作用的啊

点赞  2024-11-17 23:25
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复