我一直在尝试了解带有 cortex m7 的 stm32f69 微控制器板上的工作原理。我在显示器上找到了一个写 hello world 的教程,但我可以让它在我的板上工作。这是我正在使用的代码
#include "stm32f769xx.h"
#include "stm32f769i_discovery.h"
#include "stm32f769i_discovery_lcd.h"
#include "stm32f7xx_hal.h"
/* Private function prototypes -----------------------------------------------*/
static void LCD_Config(void);
static void SystemClock_Config(void);
static void Error_Handler(void);
static void CPU_CACHE_Enable(void);
int main(void)
{
// enable cpu cache
CPU_CACHE_Enable();
//
HAL_Init();
//
LCD_Config();
/* Our main starts here */
uint16_t ypos = 0, ymax = 0;
int8_t yincr = 1;
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
while(1) {
if(ypos == 0) {
yincr = 1;
ymax = BSP_LCD_GetYSize();
} else {
yincr = -1;
ymax = 0;
}
for(;yincr == 1 ? ypos < BSP_LCD_GetYSize() - Font24.Height : ypos > 0; ypos+=yincr) {
BSP_LCD_DisplayStringAt(0, ypos, (uint8_t*)"Hello to everyone!", CENTER_MODE);
}
}
for(;;);
}
/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;
/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 400;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 8;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
while(1) { ; }
}
/* Activate the OverDrive to reach the 200 MHz Frequency */
ret = HAL_PWREx_EnableOverDrive();
if(ret != HAL_OK)
{
while(1) { ; }
}
/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6);
if(ret != HAL_OK)
{
while(1) { ; }
}
}
static void LCD_Config(void)
{
/* LCD Initialization */
BSP_LCD_Init();
/* LCD Initialization */
BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
/* Enable the LCD */
BSP_LCD_DisplayOn();
/* Select the LCD Background Layer */
BSP_LCD_SelectLayer(0);
/* Clear the Background Layer */
BSP_LCD_Clear(LCD_COLOR_BLACK);
/* Configure the transparency for background */
BSP_LCD_SetTransparency(0, 100);
}
/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
static void Error_Handler(void)
{
/* Turn LED1 on */
BSP_LED_On(LED1);
while(1)
{
}
}
/**
* @brief CPU L1-Cache enable.
* @param None
* @retval None
*/
static void CPU_CACHE_Enable(void)
{
/* Enable I-Cache */
SCB_EnableICache();
/* Enable D-Cache */
SCB_EnableDCache();
}
当我检查时,我一直在暂停执行,我注意到有一个函数专门停止执行,称为 HAL_DSI_ShortWrite()。在此函数中,它陷入以下循环
/* Wait for Command FIFO Empty */
while((hdsi->Instance->GPSR & DSI_GPSR_CMDFE) == 0)
{
/* Check for the Timeout */
if((HAL_GetTick() - tickstart ) > DSI_TIMEOUT_VALUE)
{
/* Process Unlocked */
__HAL_UNLOCK(hdsi);
return HAL_TIMEOUT;
}
}
它在 st board 制造商提供的库中提供。在调用 BSP_LCD_Init 之前我应该做些什么吗?