FreeRTOS vTaskDelayUntil 函数

 vTaskDelayUntil 使任务以一定周期调度

void vTaskDelayUntil( TickType_t *pxPreviousWakeTime,
                      const TickType_t xTimeIncrement );
需要使能FreeRTOSConfig.h中的
#define INCLUDE_vTaskDelayUntil             1

1 ticks是多少ms?
#define configTICK_RATE_HZ   ((TickType_t)1000) //1000HZ即1ms
//可配置范围为1-1000


例程:http://www.freertos.org/vtaskdelayuntil.html
// Perform an action every 10 ticks.
 void vTaskFunction( void * pvParameters )
 {
 TickType_t xLastWakeTime;
 const TickType_t xFrequency = 10;

     // Initialise the xLastWakeTime variable with the current time.
     xLastWakeTime = xTaskGetTickCount();//获取当前tick

     for( ;; )
     {
         // Wait for the next cycle.
         vTaskDelayUntil( &xLastWakeTime, xFrequency );
         // Perform action here.
     }
 }

你可能感兴趣的:(FreeRTOS)