//
使用外部高速晶振
外部高速晶振为8M(根据开发板上的晶振频率设置),使用 PLLCLK,HSE 选项
USART1 使用 Asynchronous,PA9,PA10引脚(USART1 引脚根据开发板上引脚设置)
设置MDK ARM,使用keil
printf 函数使用,需要勾选Use Micro LIB 复选框
Download 代码后即可运行,勾选Reset and Run 复选框
"Error: Not a genuine ST Device! Abort connection"
Enable复选框 取消 打勾
//
../Core/Src/main.c(48): error: #20: identifier "FILE" is undefined
需要包含头文件: stdio.h
/* USER CODE BEGIN Includes */
#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 ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
/* USER CODE BEGIN PV */
int fputc(int ch, FILE *f)
{
while ((USART1->SR & 0X40) == 0);
USART1->DR = (uint8_t) ch;
return ch;
}
/* USER CODE END PV */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
printf("TEST\r\n");
HAL_Delay(1000);
}
/* USER CODE END 3 */
//
//
//