STEmWin with Touch Screen on STM32F746G Dicovery – Part 1

Dear readers!

 

It seems that there are too many changes in CubeMX for this tutorial to work. Please do not follow it! I will soon make a new tutorial on this. Once I get some info back from ST.

 

Thank you!

Slemi

 

 

In this series of articles I will show you how to get STEmWin working on STM32F746G Discovery board.

I used this site to help me make everything work. There is also a lot deeper explanation of how everything works. I will only show the steps needed to make everything work. Now let’s start!

Warning! This tutorial works until F7 version 1.8.0 in CubeMX it does not work in 1.9.0 and in latest 1.11.0. I will try to figure out a solution for latest version, which includes STEmWin, in new tutorial. I have found solution for latest (1.11.0) version. It was my fault because there was problem with clock configurtaion.

I could explain how to set everything but I rather prepared an .ioc file for use with CubeMX. Download it and open it with CubeMX. It can be downloaded here. (Right click -> Save As…)

Here is screenshot of correct clock configuration (right click and open in new window or download to see full size):

After that we need to set project settings (we need to adjust everything marked red) and click Ok:

Then we need to generate project and open it in SW4STM32:

  • generating

  • opening

  • confirmation of sucsessful opening

Now we need to test everything os okay. We do this by right clicking on project we just inported and selecting Build Project:

Well it won’t work, since there is some bug present. It will show four errors in main.c: *Correction: With version 1.8.0 of Cube Firmware for F7 this error no longer appears!

And we need to comment out those two lines. It seems that CubeMX is ahead of firmware and those functions are not yet implemented under firmware but are in CubeMX.

For the first time this takes a while and when it is finished you should see some blue text in console telling you something like “Build finished took “a lot” seconds. 🙂

This means that the project is ready for some serious coding…

 

No we will start to add components to our program. First is some BSP files (board support package files). These are needed for our hardware that is added beside microcontroler on discovery board. We can find all of BSPs inside folder of our CubeMX repository. On windos that is under “C:\Users\%USER%\STM32Cube\Repository”. There is usually more than one subfolder here. What we are interestd in is folder STM32Cube_FW_F7_Vx.x.x where x.x.x is the version, just use the latest.

We need to add three drivers here:

  • stm32746g_discovery -> main file that glues everything together
  • stm32746g_discovery_sdram -> for SDRAM
  • stm32746g_discovery_lcd -> for LCD display
  • stm32746g_discovery_ts -> for touch screen

We do this by first creating place for drivers by creating subfolder BSP, with two subfolders inc and src in it in our project. Right click on Drivers folder in project, select New and Folder.

In new window enter BSP and click Finish. This will create BSP folder.

Do the same for two subfolders inside this (BSP) folder. Finally you should have folders like screenshot below:

Now let’s add the needed files in our project. We always copy .c files in src folders and .h files in inc folders.

We need to copy

stm32746g_discovery.c
stm32746g_discovery_sdram.c
stm32746g_discovery_lcd.c
stm32746g_discovery_ts.c

from $Library_path\STM32Cube_FW_F7_VX.X.X\Drivers\BSP\STM32746G-Discovery\ to Drivers/BSP/src folder and

stm32746g_discovery.h
stm32746g_discovery_sdram.h
stm32746g_discovery_lcd.h
stm32746g_discovery_ts.h

from $Library_path\STM32Cube_FW_F7_VX.X.X\Drivers\BSP\STM32746G-Discovery\ to Drivers/BSP/inc folder

We also need drivers for Components

Create new folder under Drivers named Components.

In here we copy drivers for chip for LCD display (RK043FN48H) and chip for touch screen (FT5336)

They are found in $Library_path\STM32Cube_FW_F7_VX.X.X\Drivers\BSP\Components\ for these we copy complete folder for each in our Components subfolder:

We need to add touch screen function and for this we need one file “ts.h”

First we need to create Common subfolder under Components and then copy ts.h from $Library_path\STM32Cube_FW_F7_VX.X.X\Drivers\BSP\Components\Common\ into it.

We also need fonts for display. We copy these into Utilities folder under Drivers we also need to create. They are found in $Library_path\STM32Cube_FW_F7_VX.X.X\Utilities\Fonts\

Now we have all the files where they need to be for now, but if we try to compile, we get error of files not found, that is because we haven’t defined the included directories yet. We do this now by right clicking on project name and selecting Properties.

Then go to: C/C++ General -> Paths and Symbols and select GNU C

Next click Add and add all of the following:

It should look something like this after you are finished: And then just click Ok.

We also need to add a few include files into our main.c file so that it is used when compiling:

Now it is time to try to compile to see if everything is Ok…

…believe it or not it doesn’t work yet. 🙁 It says there is problem with fonts. To solve this we need to comment a few lines of code in ‘$Project_name\Drivers\BSP\src\stm32746g_discovery_lcd.c’:

Now it should compile Ok. And this concludes part 1 of our STEmWin tutorial.

Here is link to part 2 of this tutorial.

6 thoughts on “STEmWin with Touch Screen on STM32F746G Dicovery – Part 1

  1. I have followed your instructions but It has a error : D:/STM32F746/STemWin/Project/SW4STM32/STEMWIN_F7_Test/Drivers/BSP/inc/stm32746g_discovery_lcd.h:245:30: error: unknown type name ‘LTDC_HandleTypeDef’

    please, help me.

    • Hi!

      This error is explained in part 2 ot this tutorial. Just search for “FMC_SDRAM_CommandTypeDef” on the page, there I explained solution for this type of error. Please let me know if it helped.

      Gregor

  2. Recently, Cube has added a new graphic section that includes STemWIN. Have you worked with this section?I think this section simplifies the design process. But I did not understand much of this section. If it is possible to give an example with this section.Thank you.

    • Hi!

      Yes I tried it many times, but always failed… not sure how it is supposed to be used.

      Thank You for your comment!

Comments are closed.