cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F423ZHT6- ST7789H2

Meenakshi
Associate III

I sent a write data to LCD like display the RED background on the LCD panel. But it display like this-

 
 
 
 

LCD image.jpeg

this is my code part:

 

int main(void)
{

	/* USER CODE BEGIN 1 */

	/* USER CODE END 1 */

	/* MCU Configuration--------------------------------------------------------*/

	/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
	HAL_Init();

	/* USER CODE BEGIN Init */

	/* USER CODE END Init */

	/* Configure the system clock */
	SystemClock_Config();

	/* USER CODE BEGIN SysInit */

	/* USER CODE END SysInit */

	/* Initialize all configured peripherals */
	MX_GPIO_Init();
	MX_FSMC_Init();
	MX_CRC_Init();
	MX_FMPI2C1_Init();
	/* USER CODE BEGIN 2 */
	ST7789H2_Init();
	LCD_Fill(0xF800, 0, 0, 240, 240);
	
	/* USER CODE END 2 */

	/* Init scheduler */
	osKernelInitialize();

	/* USER CODE BEGIN RTOS_MUTEX */
	/* add mutexes, ... */
	/* USER CODE END RTOS_MUTEX */

	/* USER CODE BEGIN RTOS_SEMAPHORES */
	/* add semaphores, ... */
	/* USER CODE END RTOS_SEMAPHORES */

	/* USER CODE BEGIN RTOS_TIMERS */
	/* start timers, add new ones, ... */
	/* USER CODE END RTOS_TIMERS */

	/* USER CODE BEGIN RTOS_QUEUES */
	/* add queues, ... */
	/* USER CODE END RTOS_QUEUES */

	/* Create the thread(s) */
	/* creation of defaultTask */
	defaultTaskHandle = osThreadNew(StartDefaultTask, NULL, &defaultTask_attributes);

	/* USER CODE BEGIN RTOS_THREADS */
	/* add threads, ... */
	/* USER CODE END RTOS_THREADS */

	/* USER CODE BEGIN RTOS_EVENTS */
	/* add events, ... */
	/* USER CODE END RTOS_EVENTS */

	/* Start scheduler */
	osKernelStart();

	/* We should never get here as control is now taken by the scheduler */

	/* Infinite loop */
	/* USER CODE BEGIN WHILE */
	while (1)
	{
		/* USER CODE END WHILE */

		/* USER CODE BEGIN 3 */
		

	}
	/* USER CODE END 3 */
}

void LCD_Fill(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t width, uint16_t height)
{
	for (uint16_t i=0; i<height; i++)
	{
		ST7789H2_DrawHLine(RGBCode, Xpos, Ypos++, width);
	}
}

 

 

 

#include "main.h"
#include "LCD_Controller.h"


#define FMC_BANK1_REG  ((uint16_t *) 0x60000000)  // Register Address for A0
#define FMC_BANK1_DATA ((uint16_t *) 0x60000002)  // Data Address for A0 -> A0<<1 -> 0010

void LCD_IO_WriteReg(uint8_t Reg)
{
	*FMC_BANK1_REG = Reg;
}

void LCD_IO_WriteData(uint16_t RegValue)
{

	*FMC_BANK1_DATA = RegValue;
}

void LCD_IO_WriteMultipleData(uint16_t *pData, uint32_t Size)
{
	for (uint32_t i=0; i<Size; i++)
	{
		LCD_IO_WriteData(pData[i]);
	}
}

uint16_t LCD_IO_ReadData(void)
{
	return *FMC_BANK1_DATA;
}


void LCD_IO_Delay(uint32_t delay)
{
	HAL_Delay(delay);
}
void  LCD_IO_Init(void)
{
	HAL_GPIO_WritePin(MC_LCD_RESET_GPIO_Port, MC_LCD_RESET_Pin, GPIO_PIN_RESET);
	HAL_GPIO_WritePin(LCD_ENABLE_GPIO_Port, LCD_ENABLE_Pin, GPIO_PIN_RESET);
	LCD_IO_Delay(5);
//	HAL_GPIO_WritePin(BL_CONTROL_GPIO_Port, BL_CONTROL_Pin, GPIO_PIN_RESET);
//	LCD_IO_Delay(5);
	HAL_GPIO_WritePin(MC_LCD_RESET_GPIO_Port, MC_LCD_RESET_Pin, GPIO_PIN_SET);
	HAL_GPIO_WritePin(LCD_ENABLE_GPIO_Port, LCD_ENABLE_Pin, GPIO_PIN_SET);
//	HAL_GPIO_WritePin(BL_CONTROL_GPIO_Port, BL_CONTROL_Pin, GPIO_PIN_SET);

}

 

 

 Can anyone help me?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @Meenakshi ,

 

Are you using TouchGFX?
Have you looked at this guide ?

 

It is hard to help you, I don't know what ST7789H2_WritePixel does. You should double check that this function works.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

View solution in original post

8 REPLIES 8
GaetanGodart
ST Employee

Hello @Meenakshi ,

 

It seems the function you are calling to write to your screen is "LCD_Fill(0xF800, 0, 0, 240, 240);" which does this :

 

	for (uint16_t i=0; i<height; i++)
	{
		ST7789H2_DrawHLine(RGBCode, Xpos, Ypos++, width);
	}

 


I do not know what ST7789H2_DrawHLine(RGBCode, Xpos, Ypos++, width); does.

Also, this function above is not related to TouchGFX but to (I assume) the library you are using.

 

The second code you share (I don't know the name of the file) is not related to this function I think.

 

For TouchGFX, it is recommended to test the LCD control by following this guide if you put your framebuffer in internal ram and this guide if you put your framebuffer in external ram.

Furthermore, you want to do a TBD (TouchGFX Board Setup), so you should follow the board bring up guide .

 

I hope this helps! :smiling_face_with_smiling_eyes:
If this message (or another) solves your problem, I invite you to select it as "best answer".

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
GaetanGodart
ST Employee

Hello @Meenakshi ,

 

Have you been able to move forward with your issue?

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Meenakshi
Associate III

Hi @GaetanGodart , Thanks for your support.

I couldn't able to solve the problem. Still, I'm not able to display the color background. 

 

Regards,

Meena

Ok no problem.

Keep me updated when you make progress / have new questions.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)
Meenakshi
Associate III

Hi @GaetanGodart ,

I changed my code. Still I got the same output.

void LCD_FillScreen(uint16_t color)
{
    uint16_t x, y;

    for (y = 0; y < LCD_HEIGHT; y++)   // Loop through the height of the screen
    {
        for (x = 0; x < LCD_WIDTH; x++)   // Loop through the width of the screen
        {
        	ST7789H2_WritePixel(x, y, color);   // Draw a pixel with the specified color
        }
    }
}

void DisplayRedBackground(void)
{
	LCD_IO_Init();            // Initialize the LCD (if not already initialized)
    LCD_FillScreen(RED);   // Fill the screen with the red color
}

Hello @Meenakshi ,

 

Are you using TouchGFX?
Have you looked at this guide ?

 

It is hard to help you, I don't know what ST7789H2_WritePixel does. You should double check that this function works.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)

Hi @GaetanGodart ,

I'm not using TouchGFX because it is difficult for me. I can't write a code to my custom board. So, I try this way to access my LCD (FSMC + ST7789H2). But, still, I'm not getting an output. Can you please provide any example code for accessing the LCD display?

 

Hello @Meenakshi ,

 

In that case, it would be better to watch some youtube video guide:
 - https://www.youtube.com/watch?v=QURw04sQ--Y
 - https://www.youtube.com/watch?v=RWujOLXBFrc

 

It is hard for me to help you there because it will be specific to the display and board you chose.
These video guides will show you how to use a standard display with an STM32 but keep in mind that you should use the proper library that is necessary to control your own display as well as assigning the right pins, delays, etc.

 

Regards,

Gaetan Godart
Software engineer at ST (TouchGFX)