Display stops working on evaluation board STM32L4R9IDISCOVERY with a project created with TouchGFX 4.16
Hello all,
This is not a common question. It is just to report a "bug" I encountered, to get feedback from the forum about my solution and a warning to others that may face this same problem =)
I suffered some strange "behaviors" when executing a simple test with TouchGFX Designer v4.16 generated project for the board 32L4R9IDISCOVERY[1]. The display simply stop working after a while.
What I have done:
I created a project on TouchGFX version 4.16 for this board. Then I designed a screen with just an animated image.
On the main file, I created other 4 tasks that only have a delay and asm("nop") (code on below).
Behavior:
After running for a while, the display simply hangs out. But the firmware is running normally (the tasks are still running).
My analysis:
We found that in the generated (by the example board, not the TouchGFX) file "TouchGFXHAL.cpp" has some "if" on interrupt calls that caused this behavior.
When checking the
if (osKernelGetState() == osKernelRunning)its assumption that the Kernel is always running, which is not always correct. If the interrupts enter while the Kernel is scheduling, the kernel state is locked.
My solution:
if ((osKernelGetState() == osKernelRunning) || (osKernelGetState() == osKernelLocked))Further analysis:
After a lot of digging into this I noticed that the TouchGFX version 4.14 does not use cmsis on these "if"s
if (xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED)Question:
Is this a bug? And this is an acceptable solution? Or this is simply a workaround to hide the cause of other problems?
Code inserted:
Task creation:
osThreadId_t testId2;
const osThreadAttr_t testTask_attributes2 = {
.name = "testTask2",
.priority = (osPriority_t) osPriorityLow,
.stack_size = 128 * 4
};
testId2 = osThreadNew(test, NULL, &testTask_attributes2);Task function:
void test(void *argument)
{
while(1){
osDelay(100);
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop"); asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");asm("nop");
}
}The "nop"s is just to simulate something.
[1] https://www.st.com/en/evaluation-tools/32l4r9idiscovery.html