Suspending TouchGFX_Task thread when using two or more different FreeRTOS threads
I'm trying to run two threads when using TouchGFX. One is TouchGFX_Task and another is custom. Problem is that custom task requires about 30ms uninterrupted run.
Problem is that running two tasks - one is interrupted which causes issues. If TouchGFX_Task is higher priority - screen works ok, but communication with external device is interrupted in another task. If TouchGFX_Task is lower priority - screen freezes and becomes unresponsive.
Tried suspending and resuming TouchGFX_Task with osThreadSuspend() and osThreadResume() but it just stops updating screen (just like with changing priority, tried with commented/uncommented versions)
Changed Preemptive mode to Cooperative in FreeRTOS configuration but did not help.
Considering trying to use semaphores and/or mutexes however I'm unsure how to proceed with TouchGFX_Task to stop it so no issues arise when suspending and resuming task.
Or maybe there is a better way to achieve something like this when using TouchGFX ?
Below is sample code of main.c, StartTask02 is my task where time-sensitive code resides.
main.c
/* Definitions for TouchGFXTask */
osThreadId_t TouchGFXTaskHandle;
const osThreadAttr_t TouchGFXTask_attributes = {
.name = "TouchGFXTask",
.priority = (osPriority_t) osPriorityHigh,
.stack_size = 2048
};
/* Definitions for myTask02 */
osThreadId_t myTask02Handle;
const osThreadAttr_t myTask02_attributes = {
.name = "myTask02",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 1024
};
<....>
int main (void) {
<....>
osKernelInitialize();
TouchGFXTaskHandle = osThreadNew(TouchGFX_Task, NULL, &TouchGFXTask_attributes);
myTask02Handle = osThreadNew(StartTask02, NULL, &myTask02_attributes);
osKernelStart();
<....>
}
<....>
__weak void TouchGFX_Task(void *argument)
{
/* USER CODE BEGIN 5 */
for(;;)
{
osDelay(1);
}
}
void StartTask02(void *argument)
{
/* Infinite loop */
for(;;) {
//osThreadSuspend(TouchGFXTaskHandle);
<....> <--- time sensitive code goes here
//osThreadResume(TouchGFXTaskHandle);
osDelay(1000);
}
}Any help or hints to solution or further reading material is appreciated;
