[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
说明:1、本博客中使用的开发软件为MDK5(KEIL5);
2、单片机为stm32f103zet6
3、该博客适用于有一定C和单片机基础的初学者
一、下载安装MDK5
笔者之前学51的时候用的Keil4, 但是在添加芯片的时候出现困难。于是下载安装了MDK5,这个网上搜一下有
很多资源的。
二、建立一个工程
参考博客:STM32F1固件库文件讲解与基于固件库新建MDK工程模板
三、第一个例程
目的:使连接在PB5和PE5口的LED灯一闪一灭
int main(void)
{
//GPIO,General Purpose Input Output ,通用输入输出
GPIO_InitTypeDef GPIO_InitStructure;//定义一个结构体
//结构体中有三个参数,GPIO_Pin,GPIO_Speed和GPIO_Mode
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|
RCC_APB2Periph_GPIOE, ENABLE); //开启时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; // 5号脚定义为输入输出引脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //定义为推挽输出模式
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //输入输出速度为50MHz
GPIO_Init(GPIOB, &GPIO_InitStructure); //用设置好的参数初始化PB.5
GPIO_SetBits(GPIOB,GPIO_Pin_5); //对PB5引脚施加高电平,GPIO_ResetBits()为施加低电平
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; //
GPIO_Init(GPIOE, &GPIO_InitStructure); //初始化PE5
GPIO_SetBits(GPIOE,GPIO_Pin_5); //PE.5设置为高电平
while(1)
{
GPIO_ResetBits(GPIOB,GPIO_Pin_5);
GPIO_SetBits(GPIOE,GPIO_Pin_5);//同时,PB5亮,PE5灭
Delay(3000000);
GPIO_SetBits(GPIOB,GPIO_Pin_5);
GPIO_ResetBits(GPIOE,GPIO_Pin_5);//
Delay(3000000);
}
}
未完待续