2019-08-07 03:38 AM
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
2019-11-18 12:34 AM
I have this problem, too,Have you found the problem?Thanks�?
2019-11-18 01:27 AM
I have found the problem,The function [osDelayUntil] have bug ,You can use the Primitive function[vTaskDelayUntil] in [task.h]!
2019-11-18 01:58 AM
I work around tis problem and other with the use of an other IDE, actually I use KEIL...
2020-02-19 07:56 AM
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?
2020-11-16 07:30 AM
FreeRTOSConfig.h
. . . .
#define INCLUDE_vTaskDelayUntil 1
lastWakeTime = osKernelSysTick();