【ART-PI】STM32H750XBH6 RT-Thread 点亮LCD

发布于 2021-03-28 21:00:12

【ART-PI】STM32H750XBH6 - 入手篇

【ART-PI】STM32H750XBH6 - RT-Thread 最小系统移植

【ART-PI】RT-Thread Freemodbus RS485 RTU 从机

【ART-PI】RT-Thread 开启RTC 与 Alarm组件

【ART-PI】STM32H750XBH6 RT-Thread 点亮LCD

前言

  • 自己买的ART-Pi板,一直没有时间去玩转,今天有点时间,打算让它跑跑GUI.
  • 这次点亮的是ART-Pi三件套里的多媒体板上的LCD,通过原理图查看,是个SPI屏
  • 没有使用ART-Pi的BSP工程

配置与调试

  • 驱动ART-Pi自带的屏,需要通过menuconfig,配置一下

2021-03-28_200602.png

2021-03-28_200731.png

2021-03-28_200806.png

2021-03-28_200849.png

  • 需要通过menuconfig关闭板载的LCD
  • 编译,下载运行,发现,LCD无法点亮,开机卡个半死,提示SPI通信失败,【白屏】。

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
  • 查看SPI驱动,暂时没发现问题,通过软件调试,发现SPI无法正常的发送
  • 查看SPI引脚配置,发现问题,没有配置SPI2的引脚
  • 通过STM32CubeMX配置SPI2的引脚,会更新:stm32h7xx_hal_msp.c
  • 可以通过ART-Pi官网提供的例程里,把SPI2的引脚配置复制过来
/**
* @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 */
  }
}
  • 重新编译下载运行,发现LCD可以成功的点亮了

2021-03-28_205526.png

  • 通过代码查看,LCD驱动运行的是:drv_spi_ili9488.c里面的

总结

  • 遇到问题,先软件调试,认真分析,对比总结,就会有解决问题的思路
  • ART-Pi资源丰富,可以用于进一步的学习与研究
0 条评论

发布
问题