주요 내용으로 건너뛰기

MIPI-DSI 명령 모드

This scenario describes how to configure MIPI DSI interface in Command Mode and TouchGFX Generator when using a display with a Display Serial Interface (DSI) and GRAM. The example used in this article will be for 16-bit RGB565 frame buffer format and goes through configurations in STM32CubeMX.

Note
This scenario assumes that a working display driver has been developed during the Board Bringup phase. The driver must be able to transfer pixels to the display, and to control the memory writing position of the display. Check the datasheet for your display for further details.

Configuration

LTDC 구성

  • 모드
    • Display TypeRGB565 (16 bits) - DSI Mode로 설정
  • 계층 설정
    • Number of layers1 layer로 설정
    • Windows Position, Frame Buffer Line LengthFrame Buffer Number of Lines에서 화면 해상도 설정
    • Layer 0 - Pixel FormatRGB565로 설정
    • Layer 0 - Alpha constant for blending255로 설정

      LTDC 구성

  • NVIC 설정
    • LTDC global interruptLTDC global error interrupt 모두 사용하지 않으므로 비활성화해야 합니다.

      LTDC NVIC 설정

DSIHOST 구성

  • 모드
    • DSIHost를 _*Adapted Command Mode with TE Pin**으로 설정
  • 디스플레이 인터페이스
    • Color CodingRGB565 (16 bits) - DSI mode로 설정
    • Maximum Command Size를 디스플레이 폭에 맞는 숫자로 설정
    • The Refresh of the Display Frame Buffer is Triggeredmanually by Enabling the LTDC로 설정
    • 나머지 구성은 선택한 LCD HW에 따라 다릅니다

      DSIHOST 구성

  • NVIC 설정
    • DSI global interrupt 활성화

      DSIHOST NVIC 설정

TouchGFX Generator

  • 모드
    • Graphics Application 활성화
  • TouchGFX Generator
    • Display / InterfaceParallel RGB (LTDC)로 설정(여전히 애플리케이션이 통신해야 하는 컨트롤러이기 때문)
    • Application Tick SourceCustom으로 설정

      TouchGFX Generator 구성

User Code

The TouchGFX Generator can only generate a partial TouchGFX AL that configures the LTDC to transfer pixels through the DSI Host controller from the framebuffer memory to the display and synchronize the display with the TouchGFX Engine. However, all necessary handles to accomplish this are generated by the TouchGFX Generator.

Generally, for displays with embedded GRAM, the implementation of the generated TouchGFX HAL handles in TouchGFXHAL.cpp should perform the following steps to transfer pixels to the display and synchronize the display with the TouchGFX Engine:

  1. Wait for "VSYNC" (sometimes called Tearing Effect (TE) signal) to signal the TouchGFX Engine.
  2. Based on the area of the framebuffer to be redrawn, move the "display cursor" and "active window" (the region of the display being updated) to a place in GRAM that matches this area.
  3. Prepare to write incoming pixel data to GRAM. Depending on the framebuffer strategy and display interface used, this could be swapping framebuffer pointers, signaling TouchGFX Engine, or waiting for previous transfers to complete.
  4. Send pixel data.

Depending on the display used and the framebuffer strategy, the implementation of the above steps will vary.

Some of the adjustments that may be needed specifcally for DSI Command Mode interfaces are described below.

DSIHOST / LTDC 초기화 시퀀스

MX_DSIHOST_DSI_Init()에 대한 호출은 MX_LTDC_Init()보다 먼저 수행되어야 합니다. This should be handled by STM32CubeMX. If this is not correct, take care to fix the order in a user code section.

After calling HAL_DSI_Start(), switch DSIHOST clock to the DSIPHY source:

static void MX_DSIHOST_DSI_Init(void)
{
...
/* Switch to DSI PHY PLL clock */
RCC_PeriphCLKInitTypeDef PeriphClkInit;
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_DSI;
PeriphClkInit.DsiClockSelection = RCC_DSICLKSOURCE_DSIPHY;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
/* USER CODE END DSIHOST_Init 2 */
...
}

User has to add the required initialization code specific to the used LCD controller at the end of the MX_LTDC_Init() function. That code will be based on the DSI HAL APIs HAL_DSI_ShortWrite() and HAL_DSI_LongWrite():

  static void MX_LTDC_Init(void)
{
...
/* USER CODE BEGIN LTDC_Init 2 */
// Specific LCD controller's initialization code
...

// Exit Sleep Mode
if (HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P0, DSI_EXIT_SLEEP_MODE, 0x00) != HAL_OK)
{
Error_Handler();
}

HAL_Delay(120);
/* USER CODE END LTDC_Init 2 */
...
}

DSI 명령 모드에서 TouchGFXHAL 클래스 업데이트

이 애플리케이션의 첫 번째 프레임을 렌더링할 때까지 MIPI DSI 디스플레이가 켜지지 않게 할 수 있는 한 가지 방법은 TouchGFX에서 첫 번째 프레임을 렌더링할 때까지 디스플레이를 꺼진 상태로 유지하도록 TouchGFXHAL::endFrame 함수를 보호하는 것입니다. TouchGFXHAL::endFrame()을 아래와 같이 업데이트해서 PWM 출력용으로 구성된 HW 타이머를 통해 LCD와 그 백라이트를 활성화할 수 있습니다.

void TouchGFXHAL::endFrame()
{
if (!display_on)
{
display_on = true;
/* Enable the LCD, Send Display on DCS command to display */
HAL_DSI_ShortWrite(&hdsi, 0, DSI_DCS_SHORT_PKT_WRITE_P1, DSI_SET_DISPLAY_ON, 0x00);
/* Start PWM Timer channel */
(void)HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2);
/* Enable Backlight by setting Brightness to 100% */
__HAL_TIM_SET_COMPARE(&htim8, TIM_CHANNEL_2, 2U * 100);
}

TouchGFXGeneratedHAL::endFrame();
}

Supported Framebuffer Strategies

  • Single
  • Double
  • Partial - GRAM display
Further reading
See article Framebuffer Strategies for a general introduction to framebuffer strategies in TouchGFX.

DSI Command Mode usually has a high enough bandwidth to transfer pixels to GRAM fast than the display scans the pixels. This is very similar to to the FMC Parallel display interface. Therefore, the implementation steps for a working TouchGFX AL for DSI Command Mode is very similar to the FMC Parallel display interface.

Further reading
See article FMC Display Interface for more information about the TouchGFX AL implementation.

Single

Currently, no TouchGFX Board Support have a reference implementation for Single buffering with DSI Command Mode. The setup would be similar to FMC Single buffer setup, but using DSI Command Mode driver functions instead of FMC.

Double

Currently, no TouchGFX Board Support have a reference implementation for Double buffering with DSI Command Mode. The setup would be similar to FMC Double buffer setup, but using DSI Command Mode driver functions instead of FMC.

Partial - GRAM display

Currently, no TouchGFX Board Support have a reference implementation for Partial - GRAM display with DSI Command Mode. The setup would be similar to FMC Partial - GRAM display setup, but using DSI Command Mode driver functions instead of FMC.