Skip to main content

5. Display with framebuffer in external RAM

Motivation

In this step we will move the framebuffer from internal to external RAM, and make sure that the framebuffer can still be transferred to the display.

Note
Skip this step if external RAM is not relevant for your board bring up.

This step will stress test the external RAM since the display controller has certain expectations on the transfer speed. This might result in errors. Common errors are LTDC underrun, because the bandwidth of the external RAM is not high enough, or pixel errors because the RAM is configured incorrectly and is running "out of spec".

Goal

The goal in this step is to remove the framebuffer array from internal RAM and use a framebuffer in external RAM.

Verification

Here are the verification points for this section. These are similar to the verification points when the framebuffer is in internal RAM, but should be checked again, as the speed on the external memory may influence the transmission of the framebuffer to the display.

Verification PointRationale
Framebuffer is shownDisplay controller or SPI is configured and running
Updated framebuffer is shownWe know how to repeatedly transmit the framebuffer
Framerate is correctThe pixel clock and porches are configured to get the required framerate

Prerequisites

The following are the prerequisites for this step:

  • Address of the framebuffer in the external RAM

Do

We have these two tasks:

  • Place the framebuffer in external RAM
  • Setup the display controller to read from the external RAM

When the frambuffer is in external RAM, it is common practice to not allocate an array for it. You just declare a pointer to the correct address. The address in external RAM is then manually selected. It can be anywhere in the external RAM, but the start of the RAM is commonly used:

main.c
uint16_t* framebuffer = (uint16_t*)0xC0000000;  //16 bpp framebuffer

You can reuse the small test programs you created in the steps in Display Internal.

LTDC Layer configuration

Remember to change the configuration of the LTDC Layer. Since we now have a specific address for the framebuffer, we can insert that address in CubeMX (Color Frame Buffer Start Address):

Configuring LTDC Layer Parameters

Remember to remove this line from your program and the framebuffer array:

main.c
  /* USER CODE BEGIN 2 */
HAL_LTDC_SetAddress(&hltdc, framebuffer, LTDC_LAYER_1);
/* USER CODE END 2 */

If the LTDC Layer size was setup to only update a part of the display in step 03 (due to the amount of internal RAM), now is the time to redo that. Reconfigure the LTDC Layer such that the entire display is covered.