Windows电脑通过STM32CubeIDE软件运行下面代码,电脑通过ST-LINK/V2连接的Apollo STM32F429核心板(母板是Apollo STM32F4/F7/H7 BOARD V1.7):/* USER CODE BEGIN Header *//** ****************************************************************************** * @file : main.c * @brief : Main program body ****************************************************************************** * @attention * * Copyright (c) 2023 STMicroelectronics. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** *//* USER CODE END Header *//* Includes ------------------------------------------------------------------*/#include "main.h"#include "rtc.h"#include "usart.h"#include "gpio.h"/* Private includes ----------------------------------------------------------*//* USER CODE BEGIN Includes */#include <los_task.h>#include <usart.h>#include <stdio.h>/* USER CODE END Includes *//* Private typedef -----------------------------------------------------------*//* USER CODE BEGIN PTD *//* USER CODE END PTD *//* Private define ------------------------------------------------------------*//* USER CODE BEGIN PD *//* USER CODE END PD *//* Private macro -------------------------------------------------------------*//* USER CODE BEGIN PM *//* USER CODE END PM *//* Private variables ---------------------------------------------------------*//* USER CODE BEGIN PV *//* USER CODE END PV *//* Private function prototypes -----------------------------------------------*/void SystemClock_Config(void);/* USER CODE BEGIN PFP *//* USER CODE END PFP *//* Private user code ---------------------------------------------------------*//* USER CODE BEGIN 0 */int __io_putchar(int ch){ HAL_UART_Transmit(&huart1,(uint8_t*)&ch,1,2000); HAL_UART_Transmit(&huart3,(uint8_t*)&ch,1,2000); return 1;}static void *hello_task(UINT32 arg){ while(1) { printf("Hello,world!\r\n"); LOS_TaskDelay(LOS_MS2Tick(1000)); } return NULL;}UINT32 taskid;static UINT32 create_hello_task(){ UINT32 ret=LOS_OK; TSK_INIT_PARAM_S task_init_param={0}; task_init_param.pcName="hello"; task_init_param.usTaskPrio=5; task_init_param.uwStackSize=4096; task_init_param.pfnTaskEntry=hello_task; ret=LOS_TaskCreate(&taskid, &task_init_param); return ret;}static void *inspire_task(UINT32 arg){ while(1) { printf("No pains,no gains!\r\n"); LOS_TaskDelay(LOS_MS2Tick(2000)); } return NULL;}UINT32 taskid1;static UINT32 create_inspire_task(){ UINT32 ret=LOS_OK; TSK_INIT_PARAM_S task_init_param={0}; task_init_param.pcName="inspire"; task_init_param.usTaskPrio=5; task_init_param.uwStackSize=4096; task_init_param.pfnTaskEntry=inspire_task; ret=LOS_TaskCreate(&taskid1, &task_init_param); return ret;}static void *king_task(UINT32 arg){ while(1) { printf("Other tasks cannot run when I am running because my priority is higer than others!!\r\n");// LOS_TaskDelay(LOS_MS2Tick(2000)); //思�?�:为什么不用LOS_TaskDelay呢? for(int i=0;i<0xffffff;i++); } return NULL;}UINT32 taskid2;static UINT32 create_king_task(){ UINT32 ret=LOS_OK; TSK_INIT_PARAM_S task_init_param={0}; task_init_param.pcName="inspire"; task_init_param.usTaskPrio=3; task_init_param.uwStackSize=4096; task_init_param.pfnTaskEntry=king_task; ret=LOS_TaskCreate(&taskid2, &task_init_param); return ret;}/* USER CODE END 0 *//** * @brief The application entry point. * @retval int */int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_RTC_Init(); MX_USART1_UART_Init(); MX_USART3_UART_Init(); /* USER CODE BEGIN 2 */ LOS_KernelInit(); create_hello_task(); create_inspire_task(); create_king_task(); LOS_Start(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */}/** * @brief System Clock Configuration * @retval None */void SystemClock_Config(void){ RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; /** Configure the main internal regulator output voltage */ __HAL_RCC_PWR_CLK_ENABLE(); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; RCC_OscInitStruct.HSEState = RCC_HSE_ON; RCC_OscInitStruct.LSEState = RCC_LSE_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = 15; RCC_OscInitStruct.PLL.PLLN = 216; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = 4; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { Error_Handler(); } /** Activate the Over-Drive mode */ if (HAL_PWREx_EnableOverDrive() != HAL_OK) { Error_Handler(); } /** Initializes the CPU, AHB and APB buses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK |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; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { Error_Handler(); }}/* USER CODE BEGIN 4 *//* USER CODE END 4 *//** * @brief Period elapsed callback in non blocking mode * @note This function is called when TIM1 interrupt took place, inside * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * a global variable "uwTick" used as application time base. * @param htim : TIM handle * @retval None */void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){ /* USER CODE BEGIN Callback 0 */ /* USER CODE END Callback 0 */ if (htim->Instance == TIM1) { HAL_IncTick(); } /* USER CODE BEGIN Callback 1 */ /* USER CODE END Callback 1 */}/** * @brief This function is executed in case of error occurrence. * @retval None */void Error_Handler(void){ /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } /* USER CODE END Error_Handler_Debug */}#ifdef USE_FULL_ASSERT/** * @brief Reports the name of the source file and the source line number * where the assert_param error has occurred. * @param file: pointer to the source file name * @param line: assert_param error line source number * @retval None */void assert_failed(uint8_t *file, uint32_t line){ /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ /* USER CODE END 6 */}#endif /* USE_FULL_ASSERT */运行结果如下:STMicroelectronics ST-LINK GDB server. Version 7.3.0Copyright (c) 2023, STMicroelectronics. All rights reserved.Starting server with the following options: Persistent Mode : Disabled Logging Level : 1 Listen Port Number : 61234 Status Refresh Delay : 15s Verbose Mode : Disabled SWD Debug : Enabled InitWhile : EnabledWaiting for debugger connection...Debugger connectedWaiting for debugger connection...Debugger connectedWaiting for debugger connection... ------------------------------------------------------------------- STM32CubeProgrammer v2.13.0 -------------------------------------------------------------------Log output file: C:\Users\16610\AppData\Local\Temp\STM32CubeProgrammer_a15480.logST-LINK SN : 31FF71064D55333950201743ST-LINK FW : V2J46S7Board : --Voltage : 3.22VSWD freq : 4000 KHzConnect mode: Under ResetReset mode : Hardware resetDevice ID : 0x419Revision ID : Rev 5/BDevice name : STM32F42xxx/F43xxxFlash size : 1 MBytesDevice type : MCUDevice CPU : Cortex-M4BL Version : 0x91Memory Programming ...Opening and parsing file: ST-LINK_GDB_server_a15480.srec File : ST-LINK_GDB_server_a15480.srec Size : 37.33 KB Address : 0x08000000 Erasing memory corresponding to segment 0:Erasing internal memory sectors [0 2]Download in Progress:File download completeTime elapsed during download operation: 00:00:01.242Verifying ...Download verified successfully Shutting down...Exit.运行该段代码之前LCD显示屏能正常显示界面和APP,运行完LCD显示屏黑屏了。过了几天没启动板子,STM32F429开发板重新通上电源后按启动键,电源键PWR蓝灯和输入输出的DSO红灯亮和DSI黄灯亮都正常,就是LCD显示屏不显示。再次运行上面代码,黑屏还没解决,又出现新问题(ST-LINK也连接不上了):Starting server with the following options: Persistent Mode : Disabled Logging Level : 1 Listen Port Number : 61234 Status Refresh Delay : 15s Verbose Mode : Disabled SWD Debug : Enabled InitWhile : EnabledTarget no device foundError in initializing ST-LINK device.Reason: No device found on target.目前就是LCD黑屏+ST-LINK连接不上,这是代码问题?(小白按配套程序运行的,开局就两眼一黑,求助大佬~~)