gpt4 book ai didi

c - STM32CubeF7 BSP LCD尝试

转载 作者:太空宇宙 更新时间:2023-11-04 06:55:36 26 4
gpt4 key购买 nike

我正在尝试使用来自 STM32CubeF7 的 BSP 库在 stm32f769i-disco 的 LED 上显示一个字符串。但是,没有任何反应。这是代码:

#include "stm32f7xx_hal.h"
#include "stm32f769i_discovery.h"
#include "stm32f769i_discovery_lcd.h"
#include "stm32f7xx.h"
#include <stdio.h>

char str[] = "Hello from BSP LCD demo!";

void LCDInit() {
// Initialize the LCD using the BSP_LCD_Init() function.
BSP_LCD_Init();

// Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
//BSP_LCD_SelectLayer(0);
BSP_LCD_LayerDefaultInit(LTDC_DEFAULT_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
BSP_LCD_SelectLayer(LTDC_DEFAULT_ACTIVE_LAYER);

// Enable the LCD display using the BSP_LCD_DisplayOn() function.
BSP_LCD_DisplayOn();

// Clear the whole LCD using BSP_LCD_Clear() function or only one specified string line using the BSP_LCD_ClearStringLine() function.
BSP_LCD_Clear(LCD_COLOR_LIGHTGRAY);
HAL_Delay(1000);

BSP_LCD_SetBackColor(LCD_COLOR_LIGHTGRAY);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);

// Display a character on the specified line and column using the BSP_LCD_DisplayChar() function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
BSP_LCD_DisplayStringAt(100, 100, str, CENTER_MODE);
}

int main(void) {
LCDInit();
BSP_LED_Init(LED_GREEN);

while(1) {
for (int i=0;i<1000000;i++);
BSP_LED_Toggle(LED_GREEN);
}

return 0;
}

如果我删除对 LCDInit 的调用,我的 LED 会切换,如果我调用 LCDInit,则什么也不会发生(LED 不会切换)并且 LCD 保持黑色。有什么想法吗?

我基本上已经尝试按照 stm32f769i_discovery_lcd.c 中的说明进行操作,但没有成功:

2. Driver description:
---------------------
+ Initialization steps:
o Initialize the LCD using the BSP_LCD_Init() function.
o Select the LCD layer to be used using the BSP_LCD_SelectLayer() function.
o Enable the LCD display using the BSP_LCD_DisplayOn() function.

+ Options
o Configure and enable the color keying functionality using the
BSP_LCD_SetColorKeying() function.
o Modify in the fly the transparency and/or the frame buffer address
using the following functions:
- BSP_LCD_SetTransparency()
- BSP_LCD_SetLayerAddress()

+ Display on LCD
o Clear the whole LCD using BSP_LCD_Clear() function or only one specified string
line using the BSP_LCD_ClearStringLine() function.
o Display a character on the specified line and column using the BSP_LCD_DisplayChar()
function or a complete string line using the BSP_LCD_DisplayStringAtLine() function.
o Display a string line on the specified position (x,y in pixel) and align mode
using the BSP_LCD_DisplayStringAtLine() function.
o Draw and fill a basic shapes (dot, line, rectangle, circle, ellipse, .. bitmap)
on LCD using the available set of functions.

编辑:使用 OpenOCD 调试时,如果我在 BSP_LCD_Init() 行设置断点,gdb 会挂起。如果我再次运行调试器,我可以看到程序卡在了 WWDG_IRQHandler () 处。

最佳答案

如果这对任何人有帮助,我将发布我的问题(与 HAL 库有关):

我没有特别添加任何处理覆盖中断处理程序的代码,结果甚至 HAL_init() 调用被阻止,因为我没有添加以下内容:

void SysTick_Handler(void)
{
HAL_IncTick();
}

因此,我的 HAL_Delay 将永远等待。开始时最好使用 STM32CubeF7 模板文件夹中提供的模板,这样您就不会犯和我一样的错误。

关于c - STM32CubeF7 BSP LCD尝试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45387942/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com