cancel
Showing results for 
Search instead for 
Did you mean: 

FreeRTOS CMSIS_V2: osDelayUntil go to HardFaulHandler only with optimization -O0

LéonM
Associate

Helo,

I'm discovering CUBE IDE with FREERTOS (CMSIS_V2) I work on a Nucleo STM32F401RE.

When I use the fonction osDelayUntil in -O0 optimization the execution go to HardFaultHandler just after the execution of osDelayUntil.

This problem disappears with other level of optimization.

****** in main ******

 const osThreadAttr_t defaultTask_attributes = {

  .name = "defaultTask",

  .priority = (osPriority_t) osPriorityNormal,

  .stack_size = 128

 };

 defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

void StartDefaultTask(void *argument)

{

 /* USER CODE BEGIN 5 */

 uint32_t tick;

 tick = osKernelGetTickCount();

 /* Infinite loop */

 for(;;)

 {

tick += 1000U;           // delay 1000 ticks periodically

osDelayUntil(tick);

  HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

 }

 /* USER CODE END 5 */ 

}

Thanks,

Léon

5 REPLIES 5
Raytheon
Associate II

I have this problem, too,Have you found the problem?Thanks�?

Raytheon
Associate II

I have found the problem,The function [osDelayUntil]​ have bug ,You can use the Primitive function[vTaskDelayUntil] in [task.h]!

LéonM
Associate

I work around tis problem and other with the use of an other IDE, actually I use KEIL...

JKahn.1
Associate III

I'm having the same issue...

Attempting to use the example code from CMSIS documentation here: https://www.keil.com/pack/doc/CMSIS/RTOS2/html/group__CMSIS__RTOS__Wait.html\

Results in HardFault.

Working around currently by using

#include "FreeRTOS.h"

#include "task.h"

and running the bare FreeRTOS syntax and functions:

void StartLedBlink01(void *argument)

{

 /* USER CODE BEGIN 5 */

TickType_t lastWakeTime;

const TickType_t frequency=500;

lastWakeTime=xTaskGetTickCount();

 /* Infinite loop */

 for(;;)

 {

vTaskDelayUntil(&lastWakeTime,frequency);

  HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);

 }

 // Add termination if exit the loop accidentally

  osThreadTerminate(NULL);

 /* USER CODE END 5 */

}

Is there any way to make the CMSIS osDelayUntil() function work properly?

Cheerful_Wind
Associate III

FreeRTOSConfig.h

. . . .

#define INCLUDE_vTaskDelayUntil            1

lastWakeTime = osKernelSysTick();