Skip to main content
Karan 123
Senior
April 27, 2020
Solved

TouchGFX : FreeRTOS Queues for controlling LED from TouchGFX Button and Hardware Button to TouchGFX Text Area Update:

  • April 27, 2020
  • 22 replies
  • 9175 views

Hi,

I am working on below setup:

Software Tool Chain:

STM32CubeMX 5.6.0

STM32CubeIDE 1.3.0

TouchGFX 4.13.0 Designer

Application Template STM32F746G Discovery Kit v3.0.1

I am trying to do send/receive messages with Message Queues.

1) From TouchGFX Toggle Button to LED.

2) From Hardware Button to Text Area

as per below thread.

https://community.st.com/s/question/0D50X0000AU4zodSQB/interfacing-with-hardware-in-touchgfx-applications

Program Successfully Build . But Still not succeeded to Work on Actual Hardware.

1) From TouchGFX Toggle Button to LED.

LED is not OFF/ON with TouchGFX Toggle Button

2) From Hardware Button to Text Area Update

HardFault and/or MemManage_Handler

Because I have changed priorities and Heap .

0693W000000WTJpQAO.png

 Can anybody look attachment ? Guide me What needs to be correct ?

To solve the problem .

--

Karan

This topic has been closed for replies.
Best answer by HP_it

I think there is an error in your model.cpp

I'm referring to my own example in this video: https://www.youtube.com/watch?v=majcfxr3u2E

The model looks something like this:

extern "C"
{
	xQueueHandle messageQ;
}
 
Model::Model() : modelListener(0)
{
	messageQ = xQueueGenericCreate(1,1,0);
}

So I can see two things different in your setup:

  1. you have a osMessageQId instead of a xQueueHandle. I have no idea if they are actually the same type.
  2. in modelListener I create a queue and assign the handle to it. You don't have that call and that could be why the hardfault occurs?

Lastly you wait 10 ticks for your messages. I don't think that it is needed or it helps anything. I can't recall if the waiting is a blocking call or not. If it is you have reduced your framerate a bit.

22 replies

Karan 123
Karan 123Author
Senior
April 28, 2020

Here are Code snapshots..

Please check updated One

0693W000000WbmGQAS.png

0693W000000WbmBQAS.png

The I did also use xQueueReceive(LEDQueueHandle , &led_msg , 0) worked well on Hardware LED in same (this) application ..

My ADC , UART code working fine with Semaphore (without Queue).

I will check your code suggestion tomorrow.

Thanks

--

Karan

SimonF
Senior
February 18, 2021

Hello @Community member​ , @Martin KJELDSEN​ ,

I'm facing the same problem with the STM32L4R9-discovery.

I have a file called app_main.c in which there is the function "app_main_task" which is called from the mainTask in main.c

In the function "app_main_task" I do :

if(newMessage == true)
{
		newMessage = false;
		msg = 1;
		if(osMessageQueuePut(queueToUIHandle, &msg, 0, 0) != osOK)
 {
		//DO stuff
	 }
}

My queue is defined as : extern osMessageQueueId_t queueToUIHandle;

In Model.cpp I'm doing :

if (osMessageQueueGet(queueToUIHandle, &msg, NULL, 1) == osOK)
{
		//uint8_t i = 8; // Dummy code
		//i = i + 1; // Dummy code
		if(msg == 1)
		{
 
		}
	}

If I use uint8_t or bool or whatever there is no problem but if I use the osQueue the HardFault_Handler is called.

The Fault Analyser is telling me that : "Bus, memory management or usage fault (FORCED)" and "Attempt to switch to invalid state "INVSTATE". And sometimes I get instead "Attempt to execute an undefined instruction (UNDEFINSTR). If I put code in my if or not, if I add dummy code or not, the behaviour is different : not always the same usage fault, in some case program is working but screen is stucked, etc.

I can create a new issue but it seems to be the same problem !

Thanks,

Simon

Martin KJELDSEN
Principal III
February 19, 2021

Did you check your FreeRTOS heap settings before you started adding more tasks?

/Martin

SimonF
Senior
February 23, 2021

Hello Martin,

You are right, if I put it in a default task it seems to work but not in my defined task.

However I don't understand why my own task does not work ^^.

If you mean the "FreeRTOS Heap Usage" in CubeMX, it is correct (I still have 6000 bytes of space left).

The behaviour is the same if I create my task as static or dynamic. It is also the same if my size is 128 or 512 or even 1024.