Skip to main content
Explorer
June 11, 2025
Solved

Controlling PWM from UI with TouchGFX

  • June 11, 2025
  • 2 replies
  • 328 views

I want to control a servo motor with the PWM and I want to have a slider on the GUI to control the position of the servo motor, 
So I created a TouchGFX project added the slider and the intraction to a virtual function and I generated the code 
I opened the project in the STM32CubeIDE folder and I configured the pin 
and I created a header and a source file to develop all the necessary functions to control the servo moto (ie: Init, update of frequency...) 

When I go back to the TouchGFX Designer to upload the code, I this error that the file is not found 

 

TouchGFX/gui/src/screen1_screen/Screen1View.cpp:4:10: fatal error: PWMSer.h: No such file or directory
#include "PWMSer.h"
^~~~~~~~~~
compilation terminated.

my question : how to properly add folders and source files to such project ? and if I am doing is the wrong way please show me the correct way to do it.

Best answer by Karl Yamashita

It depends on how you've created the header and source file.

If you've right clicked, lets say the Core folder in the Project tree and clicked New>Source file, then the file(s) are added to the Root>STM32CubeIDE>User>Core folder. But the IDE doesn't have the path to that folder.

However, the IDE path is actually pointing to Root>Core>Src folder. 

 

So the easiest thing to do is to move those new files to the Root>Core>Src/Inc folders respectfully.

Then in Windows Explorer, drag and drop the files to the your project tree and Link the files. And all the existing header files that aren't showing in the Project Tree, you can drag and drop those as well so they also show in the Project Tree.

2 replies

Karl Yamashita
Karl YamashitaBest answer
Principal
June 12, 2025

It depends on how you've created the header and source file.

If you've right clicked, lets say the Core folder in the Project tree and clicked New>Source file, then the file(s) are added to the Root>STM32CubeIDE>User>Core folder. But the IDE doesn't have the path to that folder.

However, the IDE path is actually pointing to Root>Core>Src folder. 

 

So the easiest thing to do is to move those new files to the Root>Core>Src/Inc folders respectfully.

Then in Windows Explorer, drag and drop the files to the your project tree and Link the files. And all the existing header files that aren't showing in the Project Tree, you can drag and drop those as well so they also show in the Project Tree.

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
GaetanGodart
Technical Moderator
June 12, 2025

Hello @scope_nh ,

 

You could include your PWMSer.h or main.h in the Model.cpp to have access to the variables located in PWMSer.c or main.c.

Then all you have to do is to send your slider value from your screen to Model.cpp.

 

Regards,