MIPI-DSI Video Mode
This scenario describes how to configure a STM32 DSIHOST in Video Mode and TouchGFX Generator when using a display with Display Serial Interface (DSI).
The example used in this article will be for 24-bit RGB888 framebuffer format and goes through configurations in STM32CubeMX and exemplifies with generated code.
Configuration
LTDC 구성
- 모드
Display Type
을 RGB888(24 bits) - DSI Mode로 설정
- Layer Settings
Number of layers
를 1 layer로 설정Layer 0 - Pixel Format
을 RGB888로 설정Layer 0 - Alpha constant for blending
을 255로 설정
- NVIC 설정
- LCD-TFT 전역 인터럽트 활성화
DSIHOST 구성
- 모드
DSIHost
를 _*Video Mode**로 설정
- 디스플레이 인터페이스
Color Coding
을 RGB888 (24 bits) - DSI mode로 설정- 나머지 구성은 선택한 LCD HW에 따라 다릅니다.
- NVIC 설정
- DSIHOST 전역 인터럽트는 필요하지 않기 때문에 비활성화되어야 합니다.
TouchGFX Generator
- 모드
- Graphics Application 활성화
- TouchGFX Generator
Display / Interface
를 Parallel RGB (LTDC)로 설정(여전히 애플리케이션이 통신해야 하는 컨트롤러이기 때문)Application Tick Source
를 LTDC로 설정
User Code
The TouchGFX Generator can generate a full 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. Only minor adjustments may be required as 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 */
...
}
사용자는 MX_LTDC_Init()
함수의 끝에 사용된 LCD 컨트롤러에 필요한 초기화 코드를 추가해야 합니다. 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 클래스 업데이트
The generated code for the LTDC interrupt is identical to the code generated when using Parallel RGB display interface.
One way to prevent the MIPI DSI display from turning on until we've rendered the first frame in the application is to guard the function TouchGFXHAL::endFrame
to keep the display off until first frame is rendered by TouchGFX. 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 - LTDC driven display
Further reading
Reference implementation
The TouchGFX Board Setup STM32U5G9J DK1 includes a reference implementation running DSI Video Mode in RGB888 24-bit framebuffer format.