Hi,
I am new in this forum so feel free to correct me if I m in the wrong section. Thanks in advance!
So basically I am using FreeRTOS on a STM32F411 with two tasks. One is running with a simple vTaskDelay
for 10ms
and another task triggered from an interrupt running at 25kHz
. From the interrupt I perform a the following:
void DMA2_Stream0_IRQHandler(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
DMA_ClearITPendingBit(DMA2_Stream0, DMA_FLAG_TCIF0);
// Notify the task that the event has occurred
vTaskNotifyGiveFromISR(xHandleControl, &xHigherPriorityTaskWoken);
// Perform any additional ISR cleanup or context switch if required
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
and in the task
_Noreturn void vTaskControl(void *pvParameters) {
uint32_t ulNotifiedValue;
for (;;) {
GPIOC->ODR ^= GPIO_Pin_13;
xTaskNotifyWait(0x00, // Don't clear any notification bits on entry.
ULONG_MAX, // Reset the notification value to 0 on exit.
&ulNotifiedValue, // Notified value pass out in ulNotifiedValue.
portMAX_DELAY); // Block indefinitely.
GPIOC->ODR ^= GPIO_Pin_13;
.... do some stuff or nothing
}
}
I aslo tried vTaskSuspend
in the task and in the interrupt vTaskResumeFromISR
with same result.
The symptoms are: both tasks are working properly up until few seconds has passed then I have a hardfault interrupt. I removed all my code with just the time delay and the interrupt to be sure the problem isn’t comming from my code. Both tasks are working fine when the other is not created.
The config is given below:
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE 0
#define configCPU_CLOCK_HZ 100000000
#define configTICK_RATE_HZ 100000
#define configMAX_PRIORITIES 5
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 120 )
#define configMAX_TASK_NAME_LEN 16
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
#define configUSE_TASK_NOTIFICATIONS 1
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 0
#define configUSE_ALTERNATIVE_API 0
#define configQUEUE_REGISTRY_SIZE 10
#define configUSE_QUEUE_SETS 0
#define configUSE_TIME_SLICING 0
#define configUSE_NEWLIB_REENTRANT 0
#define configENABLE_BACKWARD_COMPATIBILITY 0
/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION 1
The tasks are created as follow:
xHandleManager = xTaskCreateStatic(
vTaskManager, // Function that implements the task.
"mngr", // Text name for the task.
STACK_SIZE, // Number of indexes in the xStack array.
NULL, // Parameter passed into the task.
2,// Priority at which the task is created.
xStackManager, // Array to use as the task's stack.
&xTaskManager); // Variable to hold the task's data structure.
xHandleControl = xTaskCreateStatic(
vTaskControl, // Function that implements the task.
"ctrl", // Text name for the task.
STACK_SIZE, // Number of indexes in the xStack array.
NULL, // Parameter passed into the task.
2,// Priority at which the task is created.
xStackControl, // Array to use as the task's stack.
&xTaskControl); // Variable to hold the task's data structure.
vTaskStartScheduler();
I don’t know where to start in order to solve the problem. I would be glad if you can help me or give me any hints to relevant information.
Thanks in advance!