[STM32] Keil 创建 HAL 库的工程模板

本文详细介绍了如何按照100ASK_STM32F103_MINI用户手册的步骤,在Keil中创建并配置一个使用HAL库的STM32F103项目,包括创建文件夹、添加相关文件、配置系统时钟和Keil设置等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Keil 创建 HAL 库的工程模板

跟着100ASK_STM32F103_MINI用户手册V1.1.pdf的第7章步骤进行Keil工程的创建。

1 创建相关文件夹

在文件夹下新建5个子文件夹:Core、Driver、Main、Project、SDK,如下图所示

image-20221005144721147

将下列的5个文件复制粘贴到 Core 文件夹下

"STM32Cube_FW_F1_V1.8.0\Drivers\CMSIS\Device\ST\STM32F1xx\Source\Templates\arm\startup_stm32f103xb.s"
"STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Templates\Src\system_stm32f1xx.c"
"STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Templates\Src\stm32f1xx_it.c"
"STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Templates\Inc\stm32f1xx_it.h"
"STM32Cube_FW_F1_V1.8.0\Projects\STM3210E_EVAL\Templates\Inc\stm32f1xx_hal_conf.h"

2 创建“main.c/h”和“stm32f1xx_clk.c/h”

并且在 Core 文件夹下新建"stm32f1xx_clk.h"和stm32f1xx_clk.c",这两个文件的内容分别如下

stm32f1xx_clk.h

/*  Copyright (s) 2019 深圳百问网科技有限公司
 *  All rights reserved
 * 
 * 文件名称:文件名称:stm32f1xx_clk.h
 * 摘要:
 *  
 * 修改历史     版本号        Author       修改内容
 *--------------------------------------------------
 * 2020.6.6      v01        百问科技      创建文件
 *--------------------------------------------------
*/

#ifndef __STM32F1XX_CLK_H
#define __STM32F1XX_CLK_H

#ifdef __cplusplus
extern "C" {
   
#endif

extern void SystemClock_Config(void);

#ifdef __cplusplus
}
#endif /* cplusplus */

#endif /* system_clk.h */

stm32f1xx_clk.c

/*  Copyright (s) 2019 深圳百问网科技有限公司
 *  All rights reserved
 * 
 * 文件名称:stm32f1xx_clk.c
 * 摘要:
 *  
 * 修改历史     版本号        Author       修改内容
 *--------------------------------------------------
 * 2020.6.6      v01        百问科技      创建文件
 *--------------------------------------------------
*/

#include "stm32f1xx_hal.h"
#include "stm32f1xx_clk.h"

/**
  * @brief  System Clock Configuration
  *         The system Clock is configured as follow : 
  *            System Clock source            = PLL (HSI)
  *            SYSCLK(Hz)                     = 72000000
  *            HCLK(Hz)                       = 72000000
  *            AHB Prescaler                  = 1
  *      
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值