Article count:561 Read by:1105636

Account Entry

STM32H5 evaluation | Build a development environment based on KEIL and use the SPI interface to drive the ST7789LCD display

Latest update time:2023-10-11
    Reads:

Click above to follow STM32

Source: EEWORLD forum user Da Tu Tu Copyright belongs to the original author



Build a development environment based on KEIL

ARM has many development tools, including several official ones. ST also has recommended development tools, as well as advanced graphical configuration tools, making ARM development easier and easier.
This time, the development environment for STM32H5 is set up with the purpose of saving C51 development students, giving up C51 and embracing ARM32. Therefore, STM32CubeMX was not used, but KEIL5 (uVision5), which is familiar to students, was used to build the development environment of the STM32H563 development board.
1. First download the integrated development software installation package
The version used here is version 5.0 or above. If it is version 4 or lower, it needs to be upgraded. If uVision5 is already installed, it can be skipped. Visit the www.keil.com website, enter the page as shown below, and download the KEIL installation package (about 900M).

2. Log in to st.com to download the board-level support package for the STM32H5 series (about 33M).

3. Install KEIL. Follow the installation prompts and install the KEIL integrated development software step by step. Basically, there will be no abnormalities. The installation process is very simple and will not be described in detail in this article.
4. Install the STM32H563 board-level support package. After the KEIL installation is completed, a prompt will appear when starting KEIL for the first time. The following interface allows you to select the development target board for development. Here you can select one or more for installation.

Because STM32H5 is a new product, the KEIL5 version has not yet been included. It is not included in the above list by default and needs to be added manually. The adding process is as follows:
1) Click the board tab and follow the prompts to select a local file board-level support package. Here, select the STM32H5 series board-level support package downloaded in step 2 above.

2) A prompt will appear to select the installation path. It is recommended to install it in the same root directory as KEIL.

3) The installation takes about 20 minutes. According to the installation log, some content still needs to be downloaded from the Internet. If the download fails, it means that the connection to foreign websites is not smooth. It is recommended to use scientific Internet to solve the problem.
4) After the installation is completed, in the Device tab, the chip models that support the STM32H5 series will appear. After opening, you can see the development board that supports this development board STM32H563ZI.

5. Create a new project
After installing KEIL and the board-level support package of the development board, start KEIL to create a new project. When creating, you can select the STM32H563 development board in the device/development board selection interface.

6. Select the HAL library to be added
According to the development goals, select the necessary HAL library. The startup file and Core are required. Others can be checked as needed. This allows for convenient and flexible open applications and saves chip space, allowing developers to customize the software driver layer at will. Very convenient.

7. Compile the connection code
After creating the project, add your own main.c test or application code to compile and connect.

Finally, the compilation was successful and the files burned on the board were generated.
At this point, the development and compilation environment of the development board has been successfully established.

Using SPI interface to drive ST7789LCD display

Based on the development environment established previously, we began to develop peripheral applications for the STM32H563 development board. In order to display content for subsequent experiments, this experiment first carried out the development of the LCD display driver. What is used here is the 1.14-inch serial port display of the ST7789 chip, which uses the SPI interface for communication.
1. Check the interface of ST7789 LCD display

Its resolution is 135 x 240, and it needs to connect SCL, SDA, RES, DC, CS signal lines, as well as power supply and backlight.
2. SPI interface of STM32H563
The electrical characteristics of the STM32H563 SPI interface are as follows:

When the STMH563 interface is connected to the LCD, it is set to the main mode. The timing is as follows:

3. STM32H563 connects to ST7789 hardware connection
From the data, we can know that STM32H563 has 3 sets of SPI interfaces. Here we choose the SP1 interface and use the following pins to connect to the LCD.
LCD module STM32H563 microcontroller
BL K is connected to PB2 //LCD screen backlight control signal. If control is not required, connect to 3.3V. It can also be controlled through IO.
SCK is connected to PB3 //LCD screen SPI bus clock signal

SDA is connected to PB4 //LCD screen data/command control signal
RES is connected to PB9 //LCD screen reset control signal
CS is connected to PB10 //LCD screen chip selection control signal

4. Software driver transplantation development
The ST 7789 serial port screen provides the driver routine of STM32F103. Our purpose is to transplant this driver routine to STM32H563. The code is long, please contact STM32 customer service (WeChat ID: STM32_01)
For code transplantation and development, the main modification is to put this code under the SDK of STM32H563 and modify the SPI call and related system initialization.
It should be noted that this LCD has an initial starting data of x and y. The calculation method is x=(240-w)/2, y=(320-h)/2, so x=0, y= 92, so that the content can be displayed correctly, otherwise the screen will appear blurry.
The code project under development and modification is as follows:

5. Compile and run
After modification, debugging, and programming, the ST7789 was successfully transplanted to the STM32H653.

Past recommendations:






© THE END


Service number

Follow STM32

Video number


Station B account
Click "Read the original text" to learn more


Latest articles about

 
EEWorld WeChat Subscription

 
EEWorld WeChat Service Number

 
AutoDevelopers

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building,Block B, 18 Zhongguancun Street, Haidian District,Beijing, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号