Skip to main content
Associate
November 6, 2024
Question

2.0" 320x240 Color IPS TFT using ST7789 on STM32U5 without HAL

Hey, 

I am trying to find drivers for a 320x240 adafruit display that work on the STM32U5 without using the HAL. I cannot seem to find anyone who has a ST7789 driver that does not use the HAL. Have any of you used the ST7789 with the STM32U5? Any help would be appreciated. Thanks.

This topic has been closed for replies.

6 replies

Visitor II
November 6, 2024

You can try this way:

#define ST7789_DC_PIN // Define as per your setup
#define ST7789_CS_PIN // Define as per your setup

void spi_init(void) {
 // Configure SPI registers for STM32U5
}

void st7789_writeCommand(uint8_t cmd) {
 // Set D/C pin to low for command
 GPIO_WritePin(ST7789_DC_PIN, GPIO_PIN_RESET);
 // Pull CS low to select the device
 GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_RESET);
 // Write command over SPI
 SPI_WriteData(cmd);
 // Pull CS high to release the device
 GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_SET);
}

void st7789_writeData(uint8_t data) {
 // Set D/C pin high for data
 GPIO_WritePin(ST7789_DC_PIN, GPIO_PIN_SET);
 // Pull CS low to select the device
 GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_RESET);
 // Write data over SPI
 SPI_WriteData(data);
 // Pull CS high to release the device
 GPIO_WritePin(ST7789_CS_PIN, GPIO_PIN_SET);
}

void st7789_init(void) {
 st7789_writeCommand(0x01); // Software Reset
 delay_ms(150);
 st7789_writeCommand(0x11); // Sleep Out
 delay_ms(500);
 st7789_writeCommand(0x3A); // Set Color Mode
 st7789_writeData(0x55); // 16-bit color
 st7789_writeCommand(0x29); // Display On
}

 

Andrew Neil
Super User
November 6, 2024

You missed the "does not use HAL" requirement, then!

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User
November 6, 2024

Why does it matter what the library uses internally?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate
November 6, 2024

The project I am working on is done without the HAL and I have not ever used the HAL. It would be very difficult to edit the whole project to work with the HAL.

Andrew Neil
Super User
November 6, 2024

You don't have to change the rest of the project.

There is no problem to have just the library using HAL while none of the rest of the project does.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
MOBEJ
ST Employee
November 12, 2024

hello  @Falconfighter23 , 


You can use our ST7789 driver component, which includes both .c and .h files and replace every external function call with your own custom functions. This will ensure that the driver works seamlessly with your existing codebase. Then add the st7789.c and st7789.h files to your project directory ,Include the st7789.h header file in your main code or wherever you need to use the display functions and  finally Initialize and configure the display in your main code. 

Br

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.