本文主要是介绍STM32Cubemx新建F429基础工程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
配置STM32CubeMX
配置KEY
配置USART1
配置RCC
Project Manager
Toolchain 选择 MDK-ARM
Code Generator 配置如下
GENERATE CODE 即可
配置Keil5
魔术棒配置
– Target – 勾选 Use MicroLIB
– Debug – Flash Download – 勾选Reset and Run
基础代码
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "string.h"
#include "stdio.h"
/* USER CODE END Includes */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
int fputc(int ch, FILE *f)
{HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);return ch;
}uint8_t Key_Scan(GPIO_TypeDef* GPIOx,uint16_t GPIO_Pin){if (HAL_GPIO_ReadPin(GPIOx,GPIO_Pin) == RESET ) {while (HAL_GPIO_ReadPin(GPIOx,GPIO_Pin) == RESET);return RESET;} elsereturn SET;}
/* USER CODE END 0 */
/* Infinite loop *//* USER CODE BEGIN WHILE */while (1){if(Key_Scan(KEY_GPIO_Port, KEY_Pin) == RESET){printf("key pressed\r\n");}/* USER CODE END WHILE *//* USER CODE BEGIN 3 */}
编译,下载程序,就能看到按下按钮串口打印输出的现象了
这篇关于STM32Cubemx新建F429基础工程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!