HI ,everyone
I am trying to use Tickless mode. I have set #define configUSE_TICKLESS_IDLE 1 and ensured that no other interrupts are enabled. However, the ulExpectedIdleTime that I print out is always 3.(but my task has 1000ms delay time)
I’m not sure what else needs to be adjusted. Could someone please help?
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
time_log();
printf("StartTask01\n");
osDelay(1000);
}
/* USER CODE END 5 */
}
__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* place for user code */
printf("ulExpectedIdleTime:%ld\n");
}
Here is my code. Besides setting #define configUSE_TICKLESS_IDLE 1 and creating a task, I haven’t done anything else.
static void MX_GPIO_Init(void)
{
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOG_CLK_ENABLE();
HAL_PWREx_EnableVddIO2();
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Init scheduler */
osKernelInitialize();
/* USER CODE BEGIN RTOS_MUTEX */
/* add mutexes, ... */
/* USER CODE END RTOS_MUTEX */
/* USER CODE BEGIN RTOS_SEMAPHORES */
/* add semaphores, ... */
/* USER CODE END RTOS_SEMAPHORES */
/* USER CODE BEGIN RTOS_TIMERS */
/* start timers, add new ones, ... */
/* USER CODE END RTOS_TIMERS */
/* USER CODE BEGIN RTOS_QUEUES */
/* add queues, ... */
/* USER CODE END RTOS_QUEUES */
/* Create the thread(s) */
/* creation of defaultTask */
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
/* USER CODE END RTOS_THREADS */
/* USER CODE BEGIN RTOS_EVENTS */
/* add events, ... */
/* USER CODE END RTOS_EVENTS */
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
printf("StartTask01\n");
osDelay(1000);
// vTaskDelay( pdMS_TO_TICKS( 1000 ) );
}
/* USER CODE END 5 */
}
__weak void PreSleepProcessing(uint32_t ulExpectedIdleTime)
{
/* place for user code */
printf("ulExpectedIdleTime:[%d]\n", ulExpectedIdleTime);
}
When I say complete code, I mean the complete project that I can build and try. Either you can zip it up and attach or put in a GitHub repo and share the link.