2019-01-05 02:08 PM
I am trying to add an additional task to my TouchGFX project. The purpose of the additional task is to control stepper motors. I am following the procedure given in the c_task_conderser_example from the TouchGFX website.
My problem is that whenever I add a task my display freezes. This occurs even if the task is a simple task that does nothing.
Here is my code:
void stepperTask(void const * argument). <---- most simple task I could create
{
for(;;)
{
// vTaskDelay(500);
osDelay(500);
}
}
int main(void)
{
HAL_Init();
[BUNCH OF INITIALIZATION CODE REMOVED FROM HERE TO IMPROVE CLARITY]
/* Initialise the graphical hardware */
GRAPHICS_HW_Init();
/* Initialise the graphical stack engine */
GRAPHICS_Init();
/* Create the thread(s) */
/* definition and creation of defaultTask */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
/* add threads, ... */
osThreadDef(stepperTask1, stepperTask, osPriorityNormal, 0, 4096);
osThreadCreate(osThread(stepperTask1), NULL); <----- the display works if I comment this out. If not commented out, the display freezes.
osKernelStart();
Also, when I add the 2nd task, I get the following warnings but I'm not sure what they mean:
Building file: /Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp
Invoking: MCU G++ Compiler
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/SW4STM32/StepperController/Debug
arm-none-eabi-g++ -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 '-D__weak=__attribute__((weak))' '-D__packed="__attribute__((__packed__))"' -DUSE_HAL_DRIVER -DSTM32F746xx -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/FATFS/Target" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/FATFS/App" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Inc" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/target" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/USB_HOST/App" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/USB_HOST/Target" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/generated/fonts/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/generated/texts/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/generated/images/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/generated/gui_generated/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/TouchGFX/gui/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/ST/TouchGFX/touchgfx/framework/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Drivers/STM32F7xx_HAL_Driver/Inc" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FatFs/src" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FreeRTOS/Source/include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/ST/STM32_USB_Host_Library/Core/Inc" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Inc" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Drivers/CMSIS/Device/ST/STM32F7xx/Include" -I"/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Drivers/CMSIS/Include" -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fno-exceptions -fno-rtti -MMD -MP -MF"Application/User/Core/main.d" -MT"Application/User/Core/main.o" -o "Application/User/Core/main.o" "/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp"
In file included from /Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp:53:0:
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp: In function 'int main()':
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h:470:54: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
{ #name, (thread), (priority), (instances), (stacksz)}
^
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp:262:3: note: in expansion of macro 'osThreadDef'
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
^~~~~~~~~~~
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h:470:54: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
{ #name, (thread), (priority), (instances), (stacksz)}
^
/Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp:267:3: note: in expansion of macro 'osThreadDef'
osThreadDef(stepperTask1, stepperTask, osPriorityNormal, 0, 4096);
^~~~~~~~~~~
Finished building: /Users/clark/Documents/EclipseWorkspaces/STM32_Workspace/StepperController/Core/Src/main.cpp
2019-01-08 11:59 PM
> when I add the 2nd task, I get the following warnings but I'm not sure what they mean
What @Pavel A. said. Also, to explain what happens, "you're" passing a string literal (name of task) which should be a const char*, but CMSIS OS treats it as char *.
2019-01-09 06:01 AM
Ahhhh! Thanks for that. It looks like it will be simple to eliminate the warnings.
Update - It wasn't simple. Actually, after playing with it a bit, I have no idea how to eliminate this warning. In fact, I don't think it is possible to fix this because CubeMX will overwrite any changes I make.
2019-01-09 07:33 AM
When I changed my heap size in FreeRTOSConfig.h, at first I just edited line 106. But then later, CubeMX overwrote it. So I then added a new line at 175 which has my correct heap size. And now I am getting numerous warning: "configTOTAL_HEAP_SIZE" redefined.
Am I correct to think it is impossible to get rid of warnings?
2019-01-09 12:30 PM
Your main.cpp file needs this:
https://stackoverflow.com/a/12994075
Also it's often useful to separate C code in *.c/*.h files and C++ code in *.cpp/*.hpp files.
2019-09-02 07:26 AM
Hi
I'm not getting it working with an additional task.
When I comment GRAPHICS_MainTask() in the StartDefaultTask every task I create is working.
I do not know why I can't get any other task working without commenting GRAPHICS_MainTask().
I've also increased the heap size in the freeRTOS config.
this is how my task creation looks like:
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 4096);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
/* USER CODE BEGIN RTOS_THREADS */
osThreadDef(ledTask, StartLedTask, osPriorityAboveNormal, 0, 512);
ledTaskHandle = osThreadCreate(osThread(ledTask), NULL);
osThreadDef(ledTask1, StartLedTask1, osPriorityAboveNormal, 0, 512);
ledTask1Handle = osThreadCreate(osThread(ledTask1), NULL);
/* USER CODE END RTOS_THREADS */
/* Start scheduler */
osKernelStart();
The other two tasks are just toggeling some leds.
Does anyone have an idea what I can do to get it working ?
Best Regards
Dejan
2019-09-03 12:32 AM
Hi @Dejan Nedeljkovic,
When you start the GUI task you're setting things in motion, so a number of things could be wrong such as proper syncronization between LTDC and touchgfx framework.
I'm not completely sure what you mean by "can't get the other tasks working". Do you have more debug information? Do you know what the application is doing? Is the application running?
/Martin
2019-09-03 12:42 AM
Hi Martin
Thank you for the fast response.
I think i figured it out. I didn't connect the touchpanel to my board, so it had an error and stopped working.
Best Regards
Dejan
2019-09-03 12:55 AM
Ahh, great that you found out.
/Martin
2019-09-12 10:14 AM
I know I'm late to the party but I've done a video guide on how to set up a second task. It's available here:
https://www.youtube.com/watch?v=sTmNuwhxza8
I hope this can help someone searching for an answer in the future :)
2019-09-12 11:35 PM
You're on fire :)