Library 50- STemWin for STM32F429-Discovery

ST provides emWin library from Segger. It is professional GUI (Graphical User Interface), optimized for speed and performance for microcontrollers. ST has it’s own implementation, called STemWin. With this GUI, you can do many thing, of use simple buttons, dialogs, text boxes, to playing videos, displaying pictures, menus, etc. I suggest you that you go to segger’s website and read more about this very useful tool.

In my library, I’ve some changes from original ST’s example for STM32F429-Discovery board, because it has external ram (which is necessary for professional GUI) and LCD on board.

This library is just implementation (behind the scenes) to get emWin in working state on discovery board. How and what to do to use it is on you to take a look on emWin datasheet.



  • Use GUI on STM32F429-Discovery board
  • Compatibility with emWin professional GUI
  • External ram is used
  • 1 Layer
  • Screen rotation supported
  • Touch screen supported


  • STM32F4xx
    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx GPIO
    • STM32F4xx FMC
    • STM32F4xx LTDC
    • STM32F4xx DMA2D
    • STM32F4xx SPI
    • STM32F4xx I2C
  • TM
    • TM SPI
    • TM I2C
    • TM GPIO
    • TM STMPE811
    • TM ILI9341 LTDC
    • TM SDRAM
    • TM FONTS
    • TM DELAY
    • defines.h
    • All files are in one packet at the end of this post

Screen rotation

I’ve made support for screen rotation. You need more ram if you want screen rotation. By default this mode is disabled and if you want to use it, you have to open defines.h file, and add define like one below:

Then look at my functions and enumeration section to see how to properly use function for rotate screen.

Functions and enumerations


  • Example below provides you one progress bar and 5 buttons
  • first button is to activate other 4 buttons
  • 4 buttons are for on/off 2 leds on discovery board
ST emWin button waits to be pressed

ST emWin button waits to be pressed

ST emWin button already pressed

ST emWin button already pressed

Project available on Github, download library below.



Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • stracho

    Do you have full keil version ? :>

  • Kostas Papadopulos

    Hello Tilen.
    Nice to see you’ve done the STMemWin some examples using keil mdk.
    I never tryed using keil, because i think the size of the compiled binary was big enough.
    I really like the emWin graphical interface, fast and easy gui creation and really the documentation was very well written and helped at lot.
    Can i compile this examples using evaluation keil mdk?
    In the past i’ve used emWin for 2 projects for my studies, easy ones, using CoIDE.
    I’d like to share with you. I have them in my repo list.
    The projects are ECG_STM32F429 and RDA5807M.

  • Pingback: All STM32F4 libraries - STM32F4 Discovery()

  • Pragma

    Hi Tilen,

    This is my first post over here. First of all, I would like to thank you for this awesome work on your libraries.

    I have just downloaded and compiled your STemWin Library with the example provided above. However, when the program enters the TM_STMPE811_Init(); function, it stays there forever. I had to comment the TM_STMPE811_Init(); in order to let the program continue its execution. I will try to look into it to see if there’s anything wrong with the TS Pinout or if there’s anything else that I can do. Right now, I would really appreciate your help if you can show me how to use the Landscape mode with STemWin. It looks like this problem has been around on several forums for so long now, but no obvious solution came out, as far as I know! Any ideas?

    Thank you again!

    • Go to debug mode and tell me exact line where this stops please.

      To enable landscape mode, you have to do some connfigurations, already explained in post.
      First, enable screen rotation, then call function for screen rotation which is available in section “Functions and enumerations”. Check post.

  • Pragma

    Sorry, before I forgot to mention. TM_EMWIN_Rotate(TM_EMWIN_Rotate_90); has no effect whatsoever!

  • Pragma

    I’m so sorry, but I did not intend to spam you nor anyone else, and I really don’t understand why you’re so upset. Anyways, if you think I have just asked you before I read your post very very well and tried everything here and there beforehand, then excuse me, but you’re totally wrong! I did read your post very well, I have added the define for the rotation, and as far as I know, everything was done according to your post.

    Of course, I might have missed something, and that’s why I asked, and I thought you’re happy giving answers, and not expected such an attitude!

    If this sounds a spam to you, then you’re free to do what you deem right for you and your own website!

    • You definitelly didn’t say what you did till now, only that Rotate does not work.
      If you think that you told everything with your “…has no effect whatsoever!” comment then I appologize. I don’t have crystal sphere to think that you did and did not.
      Well, it works successfully. I’ve tested again before I made post to you.

      So, you have several options:
      1. Post you main code and defines.h file to pastebin and tell your compiler/IDE
      2. Send project to my email so I can take a look and make sure you did everything like I said and it still does not work! Then there is a bug if you did correct.

  • Pragma

    You really made me regret asking you!

    • I’ve offered you a help, if you decline it, it’s your problem.
      Have a nice coding time.

      PS: Rotation works just great 😉

  • Adam Brososky

    I am having a problem with running a few examples at the same time. When I try to initialize the DAC and the EMWIN packages EMWIN will not load the display. If I comment out initializing the DAC (like below) everything seems to work well. It looks like i am having issues with the clock being set in too many places? Any ideas?

    int main(void) {

    BUTTON_Handle hB1, hB2, hB3, hB4;

    /* Initialize system */


    /* Initialize delay functions */


    /* Initialize ADC1 on channel 0, this is pin PA0 */

    TM_ADC_Init(ADC1, ADC_Channel_0);

    /* Initialize DAC channel 1, pin PA4 */


    /* Initialize LEDs */


    /* Initialize emWin */

    if (TM_EMWIN_Init() != TM_EMWIN_Result_Ok) {

    /* Initialization error */

    while (1) {

    /* Toggle RED led */


    /* Delay */




  • Artur

    1. When i trying to build yours project with buttons have an error Undefined symbol TM_DMA2DGRAPHIC_CopyBuffer (referred from tm_stm32f4_ili9341_ltdc.o).

    2. Second project with sinus is fall if touch the screen. (using yours *.hex from github)

    3. If i trying to build my own project with buttons its always fall if touch the buttons, but it work if touch unused area. Debug don’t show where it happend and have crash too, but looks like in case if “if (GUI_GetKey() == GUI_ID_BUTTON0)” is true. Its looks like in project with sinus.

    • Ignore project with sinus. It was designed as report project for Segger forum.

      • Artur

        Ok, but buttons in this example doesn’t work, it’s always has fault in compare GUI_GetKey() with button, debugger has fault too. Green led stop blinking in random state. STMPE811 init and work correct. I’m try to use 2 version of cmsis, its dont take effect. Yours *.hex from github work correct.

        • Compiled with Keil uVision or any other?

          • Artur

            Yes, Keil 5.14

  • i opened the exmample from the folder 57-STM32F429_BUTTONS and used keil. Changed target as STM32f429i disc . Build successfully and burned also on board. Buy not showing any output on screen. The same thing occurring with me in every example. Can anyone guide me where i am doing wrong? or exact procedure? Its urgent.

    • Do you see in example code 57 anything related to lcd?

  • Febryn Ngk

    you havespeedometer library gui?

    • Check manual for segger if this is supported there.

      • Febryn Ngk

        ok thanks..

  • Febryn Ngk

    iam sorry, what pins used here? what a like i2c and spi? i2c for touch and spi for disp? or use one of them?

    • Touch is already implemented in lib. But for pins, take a look at these libs:
      I2C for I2C pins and STMPE811 to see which I2C is used for board
      SDRAM for SDRAM pins
      ILI9341 LTDC for LCD

      That’s all. Use search on site.

      • Febryn Ngk

        but i dont see how to define that pins and where i must configure my pins in there? because you just use core modul, my library modul, and gui modul? i can see where i must place my define pins? where i must place my define? there no spi.h or i2c.h or parallel comunication, its make me confuse.. iam beginer in this lcd, usually iam used 16×2 lcd hehe

        • I have no idea what is your point here? What you wanna do?

          • Febryn Ngk

            iam sorry my english too bad hehe, how i can setting pins used in this progam majerle?

          • Library already sets pins to use this program!

          • Febryn Ngk

            where i can see that pin majerle?

          • Like I said before. Documentation is in libraries itself.
            For I2C there is file tm_stm32f4_i2c.h and .c and so on. For LCD pins check ILI9341 LTDC library, for SPI check SPI library and more.

            Make some search on your own!

          • Febryn Ngk

            so i must include tm_stm32f4_i2c.h and other too? i confused in your example you not include that library, you just include gui modul and some modul, not i2c or ltdc library.. thank a lot majerle

          • GUI library includes all necessary files it needs.
            So, GUI lib includes touch library, which includes I2C library.
            LCD library includes SDRAM library and all others and so on!

            Learn C first please, then start with STM32F4 and GUI programming! 😉

          • Febryn Ngk

            i like your advice majerle,,, i will learn c, but keep learn stm32 too hehe oke i will try this, btw im not used keil i use chibi os with qt creator to edit .c, cause i dont have keil in full version majerle

          • You are using ChibiOS without knowledge about C? 😀 I hope you won’t blow something up in your house 😉

          • Febryn Ngk

            haha, maybe i will use your tutor in this web using keil or cocox, i use chibiOS cause i have friend know about that but its too hard for me, thanks

          • ran

            Hi Majerle, We need to use ili9341 connected to D0-D7, so we are trying to make the required changes in the driver. Do you think that afterwards, it can be used as-is with emWin ? Thx

          • 8-bit only?
            Anyway, yes, you can still use EMWIN. But you will have to made modifications to EMWIN driver.

          • ran

            Hi, I think the change from spi to sram, should be simply by replacing TM_SPI_Send() with TM_SDRAM_Write8() , Right? I also see that TM_SDRAM_Init() is already called in driver (although I don’t see why, becuase the attached driver uses spi only, not sdram).
            About the 8-bit limitation… I see that color is still supported with 8-bit driver. So what does this limitation of 8-bit means ?

          • No, you don’t have cleared how things works.
            Check documentations from ST about protocols.

            And no, SDRAM is initialized with care there. It is not SPI only driver!

          • ran

            Hi Majerle, Thank you very much for the time ! We intend to use ilitek9341, 16-bits per pixel in custom board (which is based on discovery).
            Can you please give some hints as to the modifications in order to work with sdram instad of spi ? The LCD is connected with pins DO-D7. Thank you very much.

  • Kiran Kadam

    hi I am working on stemwin library.tell me where are definitions for ltdc_isr_handler and dma2d_isr_handler??i am getting build error due to this.

    • Stm32f429_discovery.c file or something like that.

      • Kiran Kadam

        thanks mann

  • manju nath

    Majerle Sir ,I have got an error while compiling … then how can I fix it.
    .TargetsSTM32F429_Discoveryproject.axf: Error: L6218E: Undefined symbol TM_DMA2DGRAPHIC_CopyBuffer (referred from tm_stm32f4_ili9341_ltdc.o).

    • Add DMA2D library to project.

      • manju nath

        Yes its true, i have added tm_stm32f4_dma2d_graphic l add library to my project and its working fine Thanks Majerle Sir.

  • Jacob

    hello, I’m getting this error, what did I forget about?

    • Hi,

      looks like you don’t have included all necessary libraries into project.
      I see you are missing EMWIN basic lib, and some others.

      • Jacob

        Well, I’ve downloaded your libs from your GitHub account and extracted them. Then I’ve included path to that libs, as you can see here: Could you please point out where did I go wrong? Is it possible that there is something wrong because of Keil version which I am using (version 5.16a)?

        • Keil works ok. You have to add C files and .lib for emwin.
          Download github repository fron ne and open project directly from there. It can be your reference.

          • Jacob

            OK, so I opened project from “50-STM32F429_EMWIN” dir. Dialog occurred that I have to add device, so I added STM32F429ZI. Then I compiled main.c and error occurred “.TargetsSTM32F429_Discoveryproject.axf: error: L6050U: The code size of this image (64244 bytes) exceeds the maximum allowed for this version of the linker.”

          • Thats because you dont have license and you use free version.

          • Maciej

            I have problem with this like in first post in this disqution. I use Atollic Lite. When i added STemWin526_CM4_GCC i havent now errors, but atollic can’t make a .elf file. Did you try run this on Atollic Lite?

          • I didnt.

  • Daniel Ponzo

    Hi Tilen,
    Could you tell me how do i find “St Embedded Resource Editor GUI” or some software like this?
    apparently above mentioned is not longer available on st website.
    mthanks in advance + brads.


    • It is included in STM32Cube package.

      • Daniel Ponzo

        Thanks a lot.
        besides, congratulations for the great job you are doing. I am beginner and your web site is helping a lot.

  • Smalink


    I have an issue with the button BUTTON_SKIN_FLEX skin. With this skin enabled, my buttons don’t always refresh, or refresh just parts of buttons. Have you ever seen the issue? Any clue to resolve the problem?

    However, the default skin works great!

    Many thanks

    • Hello,

      this is a EMWIN related problem for my opinion. I think you should check Segger’s forum for that info.

  • Amit

    My logic is based on timer. When button is clicked it should start the timer and once timer expires it should change the button text. When i use 1 sec timer or less than 1 sec timer, it works perfectly. but when i increase time value to say 2sec or 1.5sec it doesn’t work. Can you please tell me where i’m making a mistake ?
    my main.c =>
    and WindowsDlg.c =>

    • Amit

      I have solved This problem. Thanks!

  • Emmanuel Fernandez

    Hi Mr. Tilen Majerle, I would Like to kindly ask your help with this message “Error: L6406E: No space in execution regions with .ANY selector matching guiconf.o(.bss)” that appears when i build my code in keil uvision. How can I solve it?

  • Mustafa

    Hi Tilen,

    I use emWin GUI and I use GuiBuilder but I dont want to wait with GUI_Delay. Because my software quite long, 1ms Timer, PID, DMA, USB, ETH, etc. I use cooperative multitasking which is i write. So how i solve this problem. I dont want to wait anywhere in my code.

    Thanks bro.

    • Is there a “must” to wait with GUI_Delay somewhere? I don’t see it.

      • Mustafa

        Yes you are right but if I dont use GUI_Delay at least GUI_Delay(1), or GUI_Exec, there is no GUI menu on the TFT screen.

        • Well, you must Execute pending tasks to transfer data to LCD.

          GUI_Delay actually really waits for 1ms, but that time instead of doing nothing inside while loop, it checks for pending tasks and makes job.

          • Mustafa

            Thanks Majerle, Did you mean that EmWin libary does not wait 1ms, it checks for pending tasks and makes job.
            I dont understand how GUI task and GUI delay do it works exactly.

          • No, I don’t mean that.

            When you call GUI_Delay with specific ms to delay, it actually don’t just wait, but checks also that time when you wanna delay for pending tasks if it has to do some job inside GUI. If it has, then it do the job and waits if this job is done before delay has finished.

            GUI_Exec on other hand just does the pending job, does not wait if it is not necessary.

          • Mustafa

            How can I do this. If I do not use GUI_Delay or GUI_Exec in main loop. GUI does not work.
            Sory Tilen, If I missunderstant you.

          • I know, you must call GUI_Exec. If you call GUI_Delay, it will call GUI_Exec too inside.

            At least call GUI_Exec. If you don’t you can’t use it. If you don’t know how to solve problem, you have serious problems. Use interrupts to calculate PID and so on.

          • Mustafa

            I allready use 1ms interrupt for PID. I will continue GUI_Exec and investigate.
            Thank you bro.

  • Tony

    Thank you for making a awesome website!
    I have a problem when building my project from this libraries.
    Here it is:
    It seems like I need to add some libraries for those funtions. But I do not know exactly where those are.
    Thanks for helping me!