freeRTOS_10_1_1 stack overflow

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

freeRTOS_10_1_1 stack overflow

2,195 Views
zhaoyanling
Contributor III

Hallo expert,

I use freeRTOS_10_1_1, and I creat only one task. I get ADC value from ADC12, but when I change the sample into voltage, there is something wrong.

After the following floating-point is comouted,:

 /* Process the result to get the value in volts */
 adcValue = ((float) adcRawValue / adcMax) ;//* (ADC_VREFH - ADC_VREFL);

then the task sleep controlled by follwing command:

 vTaskDelay(pdMS_TO_TICKS(10));

but the task  FreeRTOS_vApplicationStackOverflowHook() will run. why ?

I changed the heap size and stack size, but it can not be solved.

I show my project as an attachment.

Could you give me some suggestion?

Labels (1)
Tags (2)
0 Kudos
8 Replies

1,863 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello,


First I would like to apologize for the late response.

I took a look into the main.c of your folder and I notice something that I had seen before while working with FreeRTOS. In your AppTask you have the following floating-point operation:

   adcRealVol[0] = ((float) adcRawValue[0] / 256)*(ADC_VREFH - ADC_VREFL);

But, you are not using for anything the adcRealVol[0] value. By default your project has optimizations and, since you are not using this value, the compiler is optimizing it. This causes some strange behavior while working with FreeRTOS. To solve this behavior that you are facing, please turn off all the optimizations. To do this go to your project properties > C/C++ Build > Settings > Standard S32DS C Compiler > Optimization > Optimization Level and select None.

pastedImage_2.png

Please let me know the results on your side.


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,863 Views
zhaoyanling
Contributor III

Hallo Jimenez,

First, thank you very much for your kind help.

I tried as your suggestion, the problem cannot be worked out.

But I found that the value of “Maximum Priorities” must be 1, then the project can work normally, shown as the following fig.

priority settng.bmp

and it seems the problem is caused by the NVIC priority grouping, the illustration of freeRTOS codes ares shown as the following fig. But I cannot understand how to set the NVIC_SetPriorityGrouping for S32K144.

explanation.bmp

I read the datasheets, and I set PRIGROUP bits of register AIRCR as this:

S32_SCB_AIRCR_PRIGROUP(0x03);

which I means to set preemptive priority is 16, and subpriority is 0.

but when I debug, the value of register S32_SCB -> AIRCR is always 0 in EmbSysRegisters view.

Could you help me again?

My questions are :

1.  I think the S32K146 support the max preemptive priority is 16. If I want to use freeRTOS in S32K144, I had better to set the preemptive priority as 16 and set subpriority as 0.

Do I get the point? Could you check if the problem is caused by the settings of interrupt priority?

2. how to effectively set the AIRCR register, especially the PRIGROUP?

 

Thank you very much!

Wish you happy!

0 Kudos

1,861 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello,

I saw that you are using FreeRTOS 10.1.1, however,  the FreeRTOS component that we have corresponds to version 10.0.1.

pastedImage_1.png

Could you please clarify where did you get version 10.1.1?

Best regards,

Victor

0 Kudos

1,862 Views
zhaoyanling
Contributor III

Hello,

I did as the article:Tutorial: FreeRTOS 10.0.1 with NXP S32 Design Studio 2018.R1 | MCU on Eclipse 

and I get the freeRTOS from : McuOnEclipse - Browse /PEx Components at SourceForge.net 

freeRTOS v10_1_1 is : Components 2018-09-30.zip

I also used Components 2019-07-18.zip which is freeRTOS v10_2_1,but the problem is also.

Could you give me some suggestions about the stack overflow reasons? 

Thank you very much! 

0 Kudos

1,862 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello,

Unfortunately, since you are using a different version of FreeRTOS than the one that comes with the SDK, I'm not able to make tests on my side to see what is cauisng this behavior. I tried to reproduce the problem that you mentioned with the version 10.0.1 and I didn't face any issues. Could you please try with the version of FreeRTOS that comes with the SDK to see if the problem persists?

Best regards,

Victor.

0 Kudos

1,862 Views
zhaoyanling
Contributor III

Hello Jimenez,

 I set PRIGROUP bits of register AIRCR as this:

S32_SCB_AIRCR_PRIGROUP(0x03);

which I means to set preemptive priority is 16, and subpriority is 0.

but when I debug, the value of register S32_SCB -> AIRCR is always 0 in EmbSysRegisters view.

Could you help me again?

My questions are :

1.   I want to set the preemptive priority as 16 and set subpriority as 0. How can I set the register of S32K144?

2.   how to effectively set the AIRCR register, especially the PRIGROUP?

0 Kudos

1,862 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hello,

Sorry for the late response.

According to the Cortex-M4 Devices Generic User Guide from ARM (link), if you want to write to this register, you must write 0x5FA to the VECTKEY field, otherwise, the processor ignores the write. For more information refer to section 4.3.5 of the User Guide mentioned before.

Best regards,

Victor.

0 Kudos

1,863 Views
zhaoyanling
Contributor III

Hello Jimenez,

Thank you very much! I will try as your suggestions.

0 Kudos