element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Blog STM32H7B3I - Create a TouchGFX Project with support for the Designer, CubeIDE and Debugger - Pt 1: Screen Works
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 4 Aug 2020 1:35 PM Date Created
  • Views 6495 views
  • Likes 2 likes
  • Comments 5 comments
  • stm32h7b3i
  • rt
  • stm32h7b3i-dk
Related
Recommended

STM32H7B3I - Create a TouchGFX Project with support for the Designer, CubeIDE and Debugger - Pt 1: Screen Works

Jan Cumps
Jan Cumps
4 Aug 2020

I'm selected for the STM32H7B3I-DK -  DISCOVERY KIT road test.

I'm working with the STMicroelectronics software that was in release version at the time I received the kit.

Versions:

  • STM32CubeIDE Version: 1.4.1
  • GNU for STM32, 7-2018 -q2 update
  • TouchGFX Designer 4.14.0
  • (HAL 1.6.0 and) 1.8.0
  • STMCubeProgrammer  2.5.0

 

1. Create a .ioc file with TouchGFX Designer

 

.ioc files are the heart of the CubeIDE MX HAL configurator. You can start a project from 0 and configure all peripherals.

But there's an easier way. You can create a throwaway project in TouchGFX Designer for this kit, and it'll put the good settings for the LCD screen right away.

To do this, start the Designer, then give this temp project a name and location.

Select the development kit as template, then click create.

image

 

Then click Generate Code top right. That's it. You now have a .ioc file ready in the subfolder where you created your project.

(If you forgot where: there's a Browse Code button right lower corner. It opens a window explorer. Navigate one directory up and you'll see the .ioc file.

Copy it to a place where you can find it back. It's a good starting point for future projects.

You can close TouchGFX Designer and delete the TouchFX project now. It's done its job.

 

2. Create a CubeIDE project based on your .ioc file

 

Start CubeIDE, and open menu File -> New -> Project ...

Then select ST -> STM32 Prooject from an existing Stm32CubeMx Configuration File (.ioc)

image

Next, and select your freshly created .ioc file.

 

image

Open

image

Finish, don't migrate if asked (unless you know how to do that. In that case please write a blog about it image ).

Let Mx generate the project.

image

If you're curious, click on the items marked with the green arrows and appreciate what's done for us. A lot is preconfigured by the .ioc file.

 

Open the TouchGFX folder of the new project, and double-click the link called ApplicationTemplate.touchgfx.part.

image

The Designer opens, with your project loaded.

 

3. First Screen and Project Completion in TouchGFX Designer

 

Draw a white box on the empty screen.

image

 

Add a toggle button (why: because it's easy to test the touch screen with it later).

image

Click Generate Code in the right upper corner.

If you want to follow along, click the Detailed Mog button in the right lower corner.

When finished, the status bar in the left lower corner says: Generate code | Done.

Close TouchGFX Designer. We've finished our design.

 

4. First Compilation and Run

 

Back to CubeIDE. Right-click on your project and select Refresh.

image

The Designer generated the remainder of the code for you. And also a new link. From now on, if you want to alter the design, select that link.

 

Right-click on the project and select Build Project.

If that's successful, let's do a first debug session.

Attention: your graphic design will not show yet. We are successful if at the end of this step, we have a black screen: no backlight, no image.

 

Plug in your development kit.

Right-click on the project and select Debug As -> STM32 Cortex-M C/C++ Application

image

Navigate to the Debugger tap and unselect Enable live expressions.

image

Press OK. The debugger loads the firmware to the controller and stops the session at the first line of the main() function.

image

This is a good opportunity to try out the debugger. You can step through the code, resume, ...

Don't be disappointed that you won't see anything, and that even if the backlight was on when starting, it will be dimmed when this line is executed:

  /* Start scheduler */
  osKernelStart();

 

We'll fix that in the next section.

When you're finished plaing, press the red stop button in the IDE to return to the edit view.

 

5. Fix the Display Initialisation

 

The CubeIDE + Designer combination doesn't implement a virtual function needed to initialise the display.

Funny enough, when you create a project with the Designer itself, this function is generated. But then you can't use the Mx HAL configurator in your IDE. Can't have it all.

 

Navigate to TouchGFX -> target. We'll edit two files there and add the missing virtual function.

image

 

First in TouchGFXHAL.hpp, add this as the last function in the public section:

 

virtual void taskEntry();

 

Save

 

Then in TouchGFXHAL.cpp, add the implementation:

 

/* USER CODE BEGIN TouchGFXHAL.cpp */
#include <touchgfx/hal/OSWrappers.hpp>

...

void TouchGFXHAL::taskEntry()
{
    enableLCDControllerInterrupt();
    enableInterrupts();

    OSWrappers::waitForVSync();
    backPorchExited();

    // Turning on display after first frame is rendered
    HAL_GPIO_WritePin(GPIOK, GPIO_PIN_7, GPIO_PIN_RESET);
    /* Assert display enable LCD_DISP_CTRL pin */
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_SET);
    /* Assert back light LCD_BL_CTRL pin */
    HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET);

    for (;;)
    {
        OSWrappers::waitForVSync();
        backPorchExited();
    }
}
/* USER CODE END TouchGFXHAL.cpp */

 

Build and Debug again

When you execute the program, the backlight switches on and your home screen appears. The touch screen doesn't work yet, so the button doesn't toggle.

image

 

Fixing the toggle button is for Part 2.

Project in the current state is attached to this post. Enjoy.

 

Related Posts
First Experience with CubeIDE
Create a TouchGFX Project with support for the Designer, CubeIDE and Debugger - Pt 1: Screen Works
Create a TouchGFX Project with support for the Designer, CubeIDE and Debugger - Pt 2: Touch Works
TouchGFX Simple Example: react on a button click
USB, freeRTOS ,Task Notifications and Interrupts
the Development Kit STMod+ Connector and Using UART2
TouchGFX Application Framework: Model, View, Presentation, Message Queue
TouchGFX Application Framework: A Mock GUI - Show Statuses, Switch Screens
TouchGFX Application Framework: MVP and the ModelListener
Write a CubeIDE MX application: Hardware Cryptography with DMA
Attachments:
STM32H7B3I-DK-roadtest_pt1_lcd_works.zip
  • Sign in to reply

Top Comments

  • DAB
    DAB over 5 years ago +1
    Good walk through Jan. DAB
  • Jan Cumps
    Jan Cumps over 5 years ago +1
    The whole story: - Pt 2: Touch Works
  • wildfootw
    wildfootw over 4 years ago


    Nice Job. Thanks
    In TouchGFXHAL.cpp

    remember to #include "stm32h7xx.h"

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • usrrsr
    usrrsr over 4 years ago

    Hello Nice explanation , 5 start from my side.

    Can you narrate the process for spi or fmc lcd like ST7735

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago

    The whole story: - Pt 2: Touch Works

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 5 years ago in reply to DAB

    It's been a 3 days drill-through, before I could write this walk-tru.... Deserves 6 stars.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 5 years ago

    Good walk through Jan.

     

    DAB

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube