[ART-PI] STM32H750XBH6 RT-Thread light up LCD

[ART-PI] STM32H750XBH6-Getting Started

[ART-PI] STM32H750XBH6-RT-Thread minimal system migration

[ART-PI] STM32H750XB-RT-Thread Freemodbus RS485 slave

[ART-PI] STM32H750XBH6-RT-Thread Turn on RTC and Alarm components

[ART-PI] STM32H750XBH6 RT-Thread light up LCD

 

Preface

  • I bought the ART-Pi board, and I have never had time to play around. I have some time today and I plan to let it run the GUI.
  • This time it’s the LCD on the multimedia board in the ART-Pi three-piece suit, which is a SPI screen when viewed through the schematic diagram.
  • BSP project without ART-Pi

 

Configuration and debugging

  • To drive the built-in screen of ART-Pi, you need to configure it through menuconfig

2021-03-28_200602.png

2021-03-28_200731.png

2021-03-28_200806.png

2021-03-28_200849.png

  • Need to turn off the onboard LCD through menuconfig
  • Compile, download and run, and found that the LCD cannot be lit, the boot card is half dead, and it prompts SPI communication failure, [white screen].

2021-03-28_202125.png

2021-03-28_205515.png

Warning: There is no enough buffer for saving async log, please increase the ULOG_ASYNC_OUTPUT_BUF_SIZE option.
[1322] I/drv.spi: spi transfer error : 1
[1322] I/drv.spi_lcd: lcd_write_cmd error. 0
[2322] I/drv.spi: spi transfer error : 1
[2322] I/drv.spi_lcd: lcd_write_data error. 0
[3322] I/drv.spi: spi transfer error : 1
[3322] I/drv.spi_lcd: lcd_write_data error. 0
[4322] I/drv.spi: spi transfer error : 1
[4322] I/drv.spi_lcd: lcd_write_data error. 0
  • Check the SPI driver, no problem is found for the time being. Through software debugging, it is found that SPI cannot be sent normally.
  • Check the SPI pin configuration, find the problem, the pin of SPI2 is not configured
  • Configure the pins of SPI2 through STM32CubeMX, it will be updated: stm32h7xx_hal_msp.c
  • You can copy the pin configuration of SPI2 in the routine provided by the ART-Pi official website
/**
* @brief SPI MSP Initialization
* This function configures the hardware resources used in this example
* @param hspi: SPI handle pointer
* @retval None
*/
void HAL_SPI_MspInit(SPI_HandleTypeDef* hspi)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(hspi->Instance==SPI1)
  {
  /* USER CODE BEGIN SPI1_MspInit 0 */

  /* USER CODE END SPI1_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI1_CLK_ENABLE();

    __HAL_RCC_GPIOB_CLK_ENABLE();
    __HAL_RCC_GPIOG_CLK_ENABLE();
    __HAL_RCC_GPIOA_CLK_ENABLE();
    /**SPI1 GPIO Configuration
    PB5     ------> SPI1_MOSI
    PG9     ------> SPI1_MISO
    PA5     ------> SPI1_SCK
    */
    GPIO_InitStruct.Pin = GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_9;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI1;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* USER CODE BEGIN SPI1_MspInit 1 */

  /* USER CODE END SPI1_MspInit 1 */
  }
  else if(hspi->Instance==SPI2) /* ART-Pi SPI LCD的引脚配置 */
  {
  /* USER CODE BEGIN SPI2_MspInit 0 */

  /* USER CODE END SPI2_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI2_CLK_ENABLE();

    __HAL_RCC_GPIOI_CLK_ENABLE();
    /**SPI2 GPIO Configuration
    PI1     ------> SPI2_SCK
    PI2     ------> SPI2_MISO
    PI3     ------> SPI2_MOSI
      */
    GPIO_InitStruct.Pin = GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
    HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

    /* SPI2 interrupt Init */
    HAL_NVIC_SetPriority(SPI2_IRQn, 0, 0);
    HAL_NVIC_EnableIRQ(SPI2_IRQn);
  /* USER CODE BEGIN SPI2_MspInit 1 */

  /* USER CODE END SPI2_MspInit 1 */
  }
  else if(hspi->Instance==SPI4)
  {
  /* USER CODE BEGIN SPI4_MspInit 0 */

  /* USER CODE END SPI4_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_SPI4_CLK_ENABLE();

    __HAL_RCC_GPIOE_CLK_ENABLE();
    /**SPI4 GPIO Configuration
    PE2     ------> SPI4_SCK
    PE5     ------> SPI4_MISO
    PE6     ------> SPI4_MOSI
    */
    GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_5|GPIO_PIN_6;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF5_SPI4;
    HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

  /* USER CODE BEGIN SPI4_MspInit 1 */

  /* USER CODE END SPI4_MspInit 1 */
  }
}
  • Recompile, download and run, and found that the LCD can be successfully lit

2021-03-28_205526.png

  • Through the code view, the LCD driver is running: drv_spi_ili9488.cinside

 

to sum up

  • If you encounter a problem, firstly debug the software, analyze carefully, compare and summarize, then you will have the idea to solve the problem.
  • ART-Pi is rich in resources and can be used for further study and research

Guess you like

Origin blog.csdn.net/tcjy1000/article/details/115287728