问题描述
我正在尝试使用来自STM32CubeF7的BSP库在stm32f769i-disco的LED上显示字符串.但是,什么也没有发生.这是代码:
I'm trying to display a string on stm32f769i-disco's LED with BSP libraries from STM32CubeF7. However, nothing happens. Here is the code:
#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会保持黑色.有什么想法吗?
If I remove the call to LCDInit, my LED toggles, if I call the LCDInit, nothing happens (the LED doesn't toggle) and the LCD stays black. Any ideas?
我基本上已经尝试过stm32f769i_discovery_lcd.c中的指示,但是没有运气:
I've basically tried following the instructions in stm32f769i_discovery_lcd.c, without luck:
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()上.
When debugging with OpenOCD, gdb hangs if I set the breakpoint at the BSP_LCD_Init() line. If I run the debugger again, I can see the program is stuck at the WWDG_IRQHandler ().
推荐答案
如果这对任何人都有帮助,我将发布原来是我的问题的内容(使用HAL库):
In case this ever helps anyone, I'm going to post what turned out to be my issue (with the HAL library):
我还没有特别添加任何处理重写中断处理程序的代码,结果甚至阻止了HAL_init()调用,因为我没有添加以下内容:
I have not particularly added any code that deals with overriding interrupt handlers, turns out even the HAL_init() call was blocked, because I had not added the following:
void SysTick_Handler(void)
{
HAL_IncTick();
}
因此,我的HAL_Delay会一直等待.刚开始时,最好使用STM32CubeF7 templates文件夹中提供的模板,这样您就不会像我一样犯同样的错误.
Because of this, my HAL_Delay's would be waiting forever. Probably best to use the templates provided in the STM32CubeF7 templates folder, when starting out, so you don't make the same mistakes as I did..
这篇关于STM32CubeF7 BSP LCD尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!