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
  • 12 replies
  • 9032 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.

12 replies

Romain DIELEMAN
ST Employee
April 27, 2020

Hi I have not looked at your code, but please look at this video and the channel. He uses the F746G disco board as well. This might really help you. If not I'll try to have a look when I have more time sorry.

/Romain

HP_it
Senior II
April 27, 2020

I've made a video series on exactly this functionality. they're based on the same tutorial you were following:

https://www.youtube.com/watch?v=43qQhrXc3n4&list=PLibkEAAdgBQ-d4LvImVNNDlYKCX0tj6aH

Especially look at video 4 and 5 in the playlist, the describe how to update the GUI from other tasks (using a queue) and updating other tasks from the GUI (using the same queue structure.

HP_it
Senior II
April 27, 2020

Also you could try to set a few breakpoints during the init process. how far do you go before you get an error?

How bit is your total stacksize in the RTOS config? it have to be larger than the combined size of your tasks (equal is not enough)

Karan 123
Karan 123Author
Senior
April 27, 2020

Hi,

@Romain Dieleman (ST Employee) and @HP (Community Member)

Many of Thanks for Update and video links. I have already seen that videos .

First Let you know I am able to PC send UART to TextArea ,

ADC analog values to to TextArea with Semaphores..

I am trying to do as per below but with STM32MXCube .

https://www.youtube.com/watch?v=jQO7zhX0e0Q&t=2062s

Only with Queues Generated by STM32MXCube 

@HP (Community Member)

In the video, I think you have not used STM32Cube for defining or configuring Tasks and Queues . Right ??

@HP (Community Member)

Yes, I can try .. I have not seen/configure stack size RTOS Config. But Sending Value UART and ADC are working perfectly without changing and looking in Total Stack Size.

--

Karan

Karan 123
Karan 123Author
Senior
April 27, 2020

Hi,

After doing some experiment , I found with

 if ( xQueueReceive(ButtonQueueHandle, &msg , (TickType_t)10) == pdTRUE)

 {

 // Queue is used as a flag, so don't check msg.

  // Full = PRESSED, Empty = Do nothing.

   btnPressed() ;

 }

Cause HardFault or MemFault..

0693W000000WUrOQAW.png

And Queue is created in main.c and not in Modal.c inside the Model::Model().

0693W000000WUuSQAW.png

--

Karan

Martin KJELDSEN
Principal III
April 27, 2020

Which line causes a hardfault? What does btnPressed() do? Later versions of EWARM have the ability to tell you the offending instruction following a hard fault

 

/Martin

Karan 123
Karan 123Author
Senior
April 27, 2020

@Martin KJELDSEN (ST Employee)

Thanks for Update ..

1) When I Button Hardware Button HardFault Occurs.

2) When I TouchGFX Toggle NO Response from LED .

3) I am using STM32CubeIDE 1.3.0 .

0693W000000WV1nQAG.png

Can you review my extracted code as attached Msg #1 .. ?

--

Karan

Karan 123
Karan 123Author
Senior
April 27, 2020

@Martin KJELDSEN (ST Employee)

1) When I used Toggle Button from TouchGFX - LED ON , OFF Worked

Actually, I missed interaction part from your webinar.

0693W000000WVjzQAG.png

2) When I pressed HardButton - HardFault Still Occurs.

(Hardware Button Just Increment the value in TextArea WildCard )

0693W000000WVlvQAG.png

Can you review my extracted code as attached Msg #1 .. ? Do I need to set / Increase total stacksize in the RTOS config ?

Thanks

--

Karan

Karan 123
Karan 123Author
Senior
April 27, 2020

Hi,

When I pressed Hardware Button - Hard Fault Still presists.

(Hardware Button - Just Increments the value in TextArea WildCard )

But Code worked on simulator Updating TextArea WildCard Perfectly ..

I have made some changes/correction in code attached at Msg #1.

Is there any issue in code or bug..? Specifically Below line responsible Hard Fault or Memory Fault.

 if ( xQueueReceive(ButtonQueueHandle, &msg , (TickType_t)10) == pdTRUE)

 {

  // Queue is used as a flag, so don't check msg.

  // Full = PRESSED, Empty = Do nothing.

   btnPressed() ;

 }

--

Karan

Martin KJELDSEN
Principal III
April 28, 2020

This is not due to a bug, it's a hardware/OS configuration issue - we just have to find it. The GUI isn't even in play yet here.

Karan 123
Karan 123Author
Senior
April 28, 2020

These are updated files here.

HP_it
HP_itBest answer
Senior II
April 28, 2020

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.

Karan 123
Karan 123Author
Senior
April 29, 2020

Hi,

@HP (Community Member)

This method works.. Thanks for that ...

@Martin KJELDSEN (ST Employee) 

1) Is it mandatory to create "Queue" inside the Model::Model() in Model.c ?

2) If Yes, Why cmsis syntax complied but same HardFault ...

 osMessageQDef(ButtonQueue, 1, uint16_t);

 ButtonQueueHandle = osMessageCreate(osMessageQ(ButtonQueue), NULL);

Or Any other Issue .. Please Update..

0693W000000WdWoQAK.png

0693W000000WdWyQAK.png

Any Way Thanks..

--

Karan

Karan 123
Karan 123Author
Senior
April 28, 2020

@HP (Community Member)

Many of Thanks for your time , code and link.

1) The Code successfully build .. Without any issue(s) and error(s).

2) From TouchGFX Button to LED .. Works well on Simulator and Board as well .

3) From Hardware Button to TouchGFX TextArea WildCard.. Works well on Simulator but NOT on Board ( Hardfault ) .

I have Listen Integratiing UI and Hardware" webinar from @Martin KJELDSEN (ST Employee) ..

Technically, Your approach in youtube video and mine approach as same (I think).

Did you run your code with Hardware Button on STM32746G-DISCO Board.?

--

Karan

HP_it
Senior II
April 28, 2020

well, I didn't use a button but I did use a queue. your button sampling code looks fine.

Did you try and change the code with my suggestions?

The simulator and hardware is similar but not completely similar so there's a pitfall.

Looking at your model..

walk through it with me.. if you get a message you call btnPressed()

Inside that method you do what? I think you intend to call the 'IncrementUpdate' method in the presenter, but you don't. you call the btnPressed() again? is that right?