STEmWin on STM32F429I-Discovery with SW4STM32 (Part 3)

In this part of tutorial we will finally get STEmWin working.

Well it has been a long time since last part 2 of this tutorial. I had to do a lot of reading and code writing to get this done.

You need to finish part 1 and part 2 to continue with this one!

Let me show you the steps to get it working.

First we need to import STEmWin files to our project.

We need to make a few directories in our project, first is GUI in root of our project and then we need two subfolders inc and lib:

Then we need to copy:

  • all .h files from C:\Users\…\STM32Cube\Repository\STM32Cube_FW_F4_V1.19.0\Middlewares\ST\STemWin\inc to inc folder we just created

  • file named STemWin540_CM4_GCC.a to lib folder we created

  • from C:\Users\…\STM32Cube\Repository\STM32Cube_FW_F4_V1.19.0\Middlewares\ST\STemWin\Config we need four files. We need GUIConf.c and LCDConf_Lin_Template.c which we copy to src folder under root of our project and we need GUIConf.h and LCDConf_Lin_Template.h which we copy to inc folder in root of our project. We also need to rename booth LCDConf_Lin_Template files to just LCDConf. We do this bi right clicking on them and selecting Rename…
  • We also need to copy file named GUI_X.c from C:\Users\Gregor\STM32Cube\Repository\STM32Cube_FW_F4_V1.19.0\Middlewares\ST\STemWin\OS folder.

Then we need to let the compiler know where it can find all this, right click on our project and select Properties.

Go to C/C++ General -> Paths and Symbols and do as following three screenshots:

Now we need to change some settings inside copied files:

  • inside LCDConf.c we need to change lines 62-77:
  • for now we also need to comment out a few lines of code (lines 160-168):
  • inside GUIConf.c we need to change line 64 to:
  • at the end of GUIConf.h we need to add #define GUI_USE_ARGB and set its value to 0:
  • we also need to add a few lines of code to main function, so that we use all this added code and later see if everything works:

    We only added last four lines of code, the ones that start with GUI_…
  • we also need a few more includes in main.c (last two):
  • and we need to initialize RAM and CRC clock:

With all this done, we can now successfuly compile our project without errors. But we are not done yet, the program compiles, but does not work!

Now comes the toughest part, glueing our previous program and STEmWin.

For this we need to change some settings inside LCD_X_DisplayDriver function in file named LCDConf.c.

I commented out two orininal lines of code and added BSP_LCD_SetLayerAddress.

To use this function we also need to include stm32f429i_discovery_lcd.h in LCDConf.c and also LCDConf.h

In LCDConf.c we also need to tell our program where SD RAM is located:

Now we can test some more STEmWin code. Put this inside main.c:

And define variable for button:

Now compile and run code an wait a few seconds and you should see this screen:

This is it for now. If I ever learn more about STEmWin I might put some more advanced tutorial up.



P.S.: If you found this helpful, I would appreciate clicking on Ad on the right side to give me a little “motivation”. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *