cancel
Showing results for 
Search instead for 
Did you mean: 

Framebuffer test for STM32H735G-DK does not work

Southbranch
Senior II

Hi,

My aim is to bring up custom display with the STM32H735G-DK board. As a first simple step I am using the existing display with an internal (small) framebuffer following the instructions given here: 3. Display with framebuffer in internal RAM | TouchGFX Documentation

See code snippets below, I am just trying to set some RGB888 colors in the framebuffer and loop through repeatedly by calling a simple method from the main(). But any other color than black or white just fails, typically shows as grey strips on the display...

Maybe I have missed something around how the RGB888 colors are stored..

Code to declare frame buffer:

// The display on the STM32H735G-DK is a RGB888 with 480 x 272 px.
// Lets use a small framebuffer for a portion of the display that
// could fit into internal RAM.
uint32_t *framebuffer[480*100];
uint32_t bufferSize = sizeof(framebuffer)/sizeof(framebuffer[0]);

Method called from main()

static void FillDisplay(void)
{
	// BLACK - works OK
	uint32_t RGB888_color = 0x00000000;
	for (uint32_t  i = 0; i < bufferSize; i++)
	{
		*(uint32_t*)(framebuffer + i)= RGB888_color;
	}
 
	// WHITE works OK
	HAL_Delay(1500);
	RGB888_color = 0xFFFFFFFF;
	for (uint32_t  i = 0; i < bufferSize; i++)
	{
		*(uint32_t*)(framebuffer + i)= RGB888_color;
	}
 
	// PINK does not work..
	HAL_Delay(1500);
	RGB888_color = 255 << 16 | 0 << 8 | 255 << 0;
	for (uint32_t  i = 0; i < bufferSize; i++)
	{
		*(uint32_t*)(framebuffer + i)= RGB888_color;
	}
}

Code that executes in the main():

   /* USER CODE BEGIN 2 */
  // Enable the display with setting high pins
  // for LCD_DISP and LCD_BL_CTRL for STM32H735G-DK
  HAL_GPIO_WritePin(GPIOD, LCD_DISP_Pin,1);
  HAL_GPIO_WritePin(GPIOG, LCD_BL_CTRL_Pin,1);
 
  // Set frame buffer to LTDC
  HAL_LTDC_SetAddress(&hltdc, (uint32_t)framebuffer, LTDC_LAYER_1);
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	  /* USER CODE END WHILE */
 
	  /* USER CODE BEGIN 3 */
	  FillDisplay();
	  HAL_Delay(1500);
  }
  /* USER CODE END 3 */
  

What am I missing here...?

Many thanks in advance for any hints

1 ACCEPTED SOLUTION

Accepted Solutions

Fine , but this all is better doing with D2DMA and for external RAM over linker section script and declare array same way as in internal.

TouchGFX handle this all for you.

View solution in original post

7 REPLIES 7
MM..1
Chief II

Try explain this FYI RGB888 is 3 byte format not UINT32 pointer format

uint32_t *framebuffer[480*100];

and show LTDC layer config.

Southbranch
Senior II

Many thanks for your reply.

Please see attached screenshots for LTDC config.

I am probably mixing something up in regards to store RGB888 3-bytes into the 4-byte format. According to Color Formats | TouchGFX Documentation a purple color RGB(255,0,255) should be represented using: uint32_t brightPurpleRGB888 = 255 << 16 | 0 << 8 | 255 << 0;

But I just can't get it to work..

Southbranch
Senior II

And here is the remaining LTDC config.

MM..1
Chief II

Your code is complete bad. You set RGB888 for layer then data need place in memory every 3 bytes.

#define BUFFERSIZE 480*100*3
uint8_t framebuffer[BUFFERSIZE];
static void FillDisplay(void)
{
	// any collor
	
	for (uint32_t  i = 0; i < BUFFERSIZE; i+=3)
	{
		framebuffer[i]= 0x00;  //R or B collor
		framebuffer[i+1]= 0x00;  //G collor
		framebuffer[i+2]= 0x00;  //R or B collor
	}

Yes, you are right, my code was bad and yours works just fine, thank you so much! :beaming_face_with_smiling_eyes:

I also got it to work with external RAM and posting it here:

#define BUFFERSIZE 480*100*3
uint8_t* framebuffer = (uint8_t*)0x70000000;
 
static void FillDisplay2(uint8_t red, uint8_t green, uint8_t blue)
{
	for (uint32_t  i = 0; i < BUFFERSIZE; i+=3)
	{
                // Works
		*(__IO uint8_t*) (framebuffer + i)= blue;  //R or B collor
		*(__IO uint8_t*) (framebuffer + i+1)= green;  //G collor
		*(__IO uint8_t*) (framebuffer + i+2)= red;  //R or B collor
 
		// Does not work...
		//*(__IO uint32_t*) (framebuffer + i) = red << 16 | green << 8 | blue << 0;
	}
}

Fine , but this all is better doing with D2DMA and for external RAM over linker section script and declare array same way as in internal.

TouchGFX handle this all for you.

Southbranch
Senior II

Thanks, yes TouchGFX will be next step for sure:thumbs_up:

I just wanted to run this simple tests to get a better understanding from ground level.