Can't add a task

asked Sep 20, 2019 in Getting started by prasanth
Dear all,

     I'm using IMXRT1064 controller and MCUXpresso platform to develop a program. I gets the example code coffee machine and download it to controller through mcpxpresso. I tries to add adc value reading while GUI is running. So i tried to create one more task but it didn't work.  While creating an adc task if i give a stack size less than GUI adc gets work but GUI won't. If adc task stacksize is higher than GUI now GUI is working. I tried to debug this code but while debug i can't see any task running in the Task list window.

  Please help me to solve my problem.

Thanks & Regards,


3 Answers

0 votes
answered Sep 20, 2019 by Tim Zierer

Hi Prasanth,


great to hear that you already have a running GUI application!

In general debugging with a RTOS could be tricky, therefore can you try to run another task without the ADC calculation. Please do this first to ensure that your second task is running properly, even when both task are active. In this task you can put something like an ‘EwPrint(“\nAny Text”)’, it’s just for test reasons.

Then I would recommend to reactivate the ADC task to clarify what’s wrong with this task or the FreeRTOS settings. I assume that you need to change some basic setting for FreeRTOS under ‘Application\Source\ FreeRTOSConfig.h’.

Within this file you can find this definitions:

#define configTOTAL_HEAP_SIZE                   ( ( size_t ) ( 10 * 1024 ) )

Could you please try to stepwise increase the heap size to make sure that your systems has enough resources to manage both task?

Can you also post here what does you terminal for serial output shows if you run both tasks? Does any exception appears or does the UI initializes correctly?


Kind regards

Tim Zierer

commented Sep 20, 2019 by prasanth
Dear  Tim Zierer,

          Ok sure. I will check that and update the screenshots.

Thanks & Regards,

commented Sep 27, 2019 by prasanth

Dear  Tim Zierer,

                I tried to debug the GUI application without using ADC. So i removed the ADC task and debug the GUI application only. But while debugging i can't see any of the task running in a task list and the heap usage also below 60%. I tried to increase " configTOTAL_HEAP_SIZE" but  due to this heap usage size only gets varied but i can't see any if the running task but touch screen is working fine. I attached a screenshot to it for your reference. Please assist me to solve this.

Main page
Task List
Heap Usage
Terminal Window
0 votes
answered Sep 27, 2019 by prasanth
Dear  Tim,

      Give me your mail ID i will send my project for your reference.


Thanks & Regards,

commented Sep 27, 2019 by Tim Zierer

Hi Prasanth,


could you please add this task in 'main.c' and check whether this tasks runs correctly on your system?

Insert this declaration part at the beginning:

  static void AdcThread( void * arg );
  int Count1 = 0;
  int Count2 = 0;

Insert this part after the Embedded Wizard thread creation:

  /* create thread that drives the ADC application... */
  EwPrint( "Create ADC thread...                         " );
  xTaskCreate( AdcThread, "Adc_Task", 100, NULL, 0, NULL );
  EwPrint( "[OK]\n" );

Insert this in 'main.c'.

static void AdcThread( void* arg )
		if(Count1 % 100000 == 0)
			EwPrint("Count2 = %d\n", Count2);
			// Insert ADC routine...


This task runs on my NXP system as it should. If it also runs correctly on your system, please insert your ADC code after '// Insert ADC routine...' and optinal remove the EwPrint() statements. As you can see, this task has a lower stack depth of '100'. Probably that was the problem with your ADC task.

Regarding to your question why the tasks aren't shown in the MCUXpresso task overview, please use the MCUXpresso manual to check whats to do to enable this feature. By the way, this feature also doesn't show the running task within my project, but they are definitely running correctly.

Hopefully this will help you.


Kind regards


commented Oct 10, 2019 by prasanth
Hi Tim,

       This Thread was running fine and i will ask about the running task to nxp. If i want to use adc how much i need to use stack depth?


Thanks & Regards,

0 votes
answered Oct 14, 2019 by prasanth
Dear Tim,

      I followed your instructions and now GUI and ADC works simultaniously. I have increased RTOS "configTOTAL_HEAP_SIZE" to 20*1024. But i need some clarification. If i use the ADC read with normal loop i gets the ADC value of 423 around it. If i use the same function in a task ADC values changed into 4050 around it. Finally i used two tasks ADC and GUI i gets 20 around it and 4030 around it both values are changed suddenly. I tried ADC polling method. What i want to do for gets the correct result?

Thanks & Regards,

commented Oct 24, 2019 by Tim Zierer
Hi Prasanth,

great to hear that it works. Actually the ADC itself is not a part of our solution. I'd like to refer you to the NXP support/forum. They propably do have experts especially for the peripherals they can help you better.

Best regards

commented Oct 25, 2019 by prasanth
Dear Tim,

      Ok sure. I will ask about this to them. Thank you very much for your response.


Thanks & Regards,


Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint