FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2017 Threads] vTaskDelay cause HardFault_HandlerPosted by matita87 on August 1, 2017 Hi
My application run on stm32F4 with FreeRTOS V9.0.0 and port files SourceportableRVDSARMCM4F (imported via RTE Keil).
The main, call some initialization functions, then create the task and then call the vTaskStartScheduler.
The task simply call vTaskDelay(1000) which never return (causing the HardFaultHandler).
The code is:
int main(void)
{
initfoo1()
initfoo2()
xTaskCreate(aTask, "name",1280, NULL, 6, NULL);
initfoo3();
vTaskStartScheduler();
}
void aTask()
{
vTaskDelay(1000);//At this time I have 2 task: this taks and the task Scheduler.
bar();//never go here, becaouse a HardFaultHandler appears before.
}
This problem appears almost always.
Note: if I remove all the function before the task creation the vTaskDelay works correctly.
What is wrong?
Could be a problem related to the main "corrupted" (stack pointer)?
If yes, how can I solve it?
Thanks all
m
vTaskDelay cause HardFault_HandlerPosted by rtel on August 2, 2017
What is wrong?
Impossible to say from the information provided, but here are some pointers to help you debug:
1) Step through the code to see where the hard fault happens. If it is hard to find because it is occuring in an interrupt (or some place other than where you are stepping) then try this technique: http://www.freertos.org/Debugging-Hard-Faults-On-Cortex-M-Microcontrollers.html
2) Did you check xTaskCreate() returned pass?
3) How do you know bar() never gets executed? Could it be executed without you knowing? Your task should either be in an infinite loop so it doesn't return or call vTaskDelete() before it exits. If bar does execute and return then the task will run off the end and crash. http://www.freertos.org/implementing-a-FreeRTOS-task.html
4) Do you have configASSERT() defined? http://www.freertos.org/a00110.html#configASSERT
5) It looks like you have enough stack, but just for good measure: http://www.freertos.org/Stacks-and-stack-overflow-checking.html
6) Are there any interrupts executing? If so, are the priorities set correctly: http://www.freertos.org/RTOS-Cortex-M3-M4.html
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|