am I doing right on creating FREERTOS project

runfirst wrote on Friday, July 12, 2013:

I am new at FreeRTOS. If I make stupid mistake on setting it up., please be patien. thanks for any help.

I have a simple app running on STM32F407 Discovery board. It runs prety well, stays for days without problem.
However, I am not satified that tasks can not run simultaneously. So I get your information online.

I  read the supported list. It does support my MCU. However it is IAR not KEIL. I dont really know how to use IAR.
So I set it up by following steps on  this post:

First step I include the FreeRTOS’s files:


2nd step I add head path:


3rd, copy the  FreeRTOSConfig.h. from Demo\CORTEX_M4F_STM32F407ZG-SK under my project

4th, Interrupt Vectors , I dont understand this part. So I have no idea how to implement this in my project.

And I also add this line before tasks starts:
NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 );

I forget when I see a post regarding this.

I make simple task:

portTASK_FUNCTION( vStartMachine,  pvParameters )
 /* Block for 500ms. */

Built it, fix some underfinded errors. then no warning no error.
Run it, well, no problem. then I add more tasks in it. I post it in another post here:

when it is running UART related task, it will stop after minutes.

When it is stopped, I click on “stop” and see it is sending out uart datas. it is Usart_SendString(USART3,“TEST STATU\r\n”); failed at :

void HardFault_Handler(void)
  /* Go to infinite loop when Hard Fault exception occurs */
  while (1)

I tried increase the stack size to 2000, heap size to 10*10240…whatever, it still stop after almost same time.

I had searched all over this forum, tried a lot experiences from others. still no luck.

Whatelse do I miss in this setting up?

Thanks a lot.

runfirst wrote on Friday, July 12, 2013:

I dont know how to modify the post. contiued above

now I find out the problem.

I dont send any data to uart, then this app can run more than 1hour.

It seems incoming datas cause stack overflow. how to prevent this happen?


rtel wrote on Friday, July 12, 2013:

My guess from this and your previous support thread is that your problem is not related to FreeRTOS, but either the driver you are using on the UART, or the integration of the driver with FreeRTOS.  I asked you a couple of time how your delay() function is implemented, but so far, unless I missed it, you have not replied on that.  Also on the point of whether your UART is using interrupts, because it could be a simple interrupt priority issue.


runfirst wrote on Saturday, July 13, 2013:

Hi Richard

I had changed my delay to vTaskDelay already.
Yes, it uses UART3 interrupt for receiving incming datas. I creat a xTaskCreate( vUSARTTask for it. how to check interrupt priority issue?

davedoors wrote on Saturday, July 13, 2013:

What is configMAX_SYSCALL_INTERRUPT_PRIORITY set to and what is the priority of the UART interrupt?

runfirst wrote on Saturday, July 13, 2013:

Uart was zero. Then i change it to 4. Now Both are 4.

runfirst wrote on Saturday, July 13, 2013:



it will stop after minutes if I config as above.
How to fix it?


rtel wrote on Saturday, July 13, 2013:

I think near the beginning of your original thread references were provided that will show the configuration you just posted is incorrect.  I could post the same links again, but would rather you went back and read what has already been posed in previous answers.


runfirst wrote on Sunday, July 14, 2013:

Hi Richard

What post do you mean?
Would you please just tell me :
What is configMAX_SYSCALL_INTERRUPT_PRIORITY I should set to and what is the priority of the UART interrupt I should set?

runfirst wrote on Monday, July 15, 2013:

Hi Richard

Now I am moving my app to your demo of CORTEX_M4F_STM32F407ZG-SK. I know it is different with my MCU.
Now, LEDs are working. UART is working too. However it sends lots of ??? receiver.

I think it is because the bauterate is incorrect. But I dont know how to calculate it by your demo.

It is my first day using IAR because you only providedemo for IAR.

runfirst wrote on Monday, July 15, 2013:

now it goes to void DebugMon_Handler(void). what is that mean?

runfirst wrote on Tuesday, July 16, 2013:

I suggest your project should get more funds that can have more tech support…
I am upset about this .
I will go for UCOS. I dont care I might spend money on it but I do care bettter tech support.
good bye here.
thanks Richard.

rtel wrote on Tuesday, July 16, 2013:

I am told that tech support for FreeRTOS is better than for most commercial OSes.  In this case every new question you have asked, spanning across two threads, has been answered, mainly by graciously pointing out where the answers to your questions can be found within the documentation.  Our aim is to maintain good documentation so there is a central resource that can be referenced by everybody, and referenced from the forum, rather than expend effort answering the same questions over and over again, where the answers will remain hidden inside a support thread and not easy to find.

My last reply to you was to say that the code you posted still had errors in it, but you have not commented on that, like you had not commented on most suggestions provided to you.

If you continue to use FreeRTOS then I would say, as I have said multiple times, that I don’t think your problem is related to FreeRTOS, and if it is, it is purely a configuration problem - like calling NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); when the page a referred you to said explicitly, in bold, and in red font to stand out, not to do that.

Good luck with your project. 


runfirst wrote on Sunday, July 28, 2013:

Hi Richard

You said my code has error. However my code runs well without OS. Anyway, I was trying to make my code to fit your OS.

I have done everything as you suggested.

At that post:

I replied you at last. But no reply back from you.

I also changed my code as you suggested. You last reply suggesting I do a hard faul tracking.
However there is no enough detail how to impletement this in my project. I pasate it in main.c. When I build it in KEIL, it gets errors.
And then you did not reply it again. I dont know what happen. so I open this post.

in this post, your last reply says dont calling NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); . I had tried it, still same.
I also tried heap1,heap2, heap3, heap4….no luck

For a good OS, it should be easy used. Or you provide enough simple details. Most ppl go for you because they dont have strong background/experience. Otherwise they can write good code without OS already. Dont expect I am same level as you. Like checking hard fault. where do I put those sample code? how do I fix problem? etc….it is not easy for a junor ppl like me


davedoors wrote on Sunday, July 28, 2013:

Well I don’t think you will find an OS that is easier, or has more publicly available examples for all experience levels or one that is better supported for that matter. There is even a tutorial book text for beginners.

Even if your code works without the OS it does not it will not interact with and have dependencies that are different when used with the OS. In this case your use of NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); is definitely an error that had already been pointed out. Your app may appear to work with this setting, but it will be unstable and given time will break. You need to call NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4) (as documented).

If you are still pursuing this I suggest using FreeRTOS V7.5.2 with configASSERT() defined because it will call assert() if you have this setting wrong.